def copyedit(*paths): """ Generates a copyedit email for graphic(s) (fab copyedit:slug1,slug2 | pbcopy) """ if paths[0] == '': print 'You must specify at least one slug, like this: "copyedit:slug" or "copyedit:slug,slug"' return #Generate Intro Copyedit Text env = Environment(loader=FileSystemLoader(['dailygraphics', 'templates']), extensions=['jinja2.ext.i18n']) #Enable translations. We're just using this for pluralization, not translating to different languages env.install_null_translations() template = env.get_template('copyedit/note.txt') graphics = [ get_graphic_template_variables(path, i) for i, path in enumerate(paths) ] note = template.render(graphics=graphics) # Gets rid of 'done' message at the end. # This suppresses output so only the graphic text # we want can be piped to the clipboard. output["status"] = False print note
def copyedit(*paths): """ Generates a copyedit email for graphic(s) (fab copyedit:slug1,slug2 | pbcopy) """ if paths[0] == '': print 'You must specify at least one slug, like this: "copyedit:slug" or "copyedit:slug,slug"' return #Generate Intro Copyedit Text env = Environment( loader=FileSystemLoader(['dailygraphics', 'templates']), extensions=['jinja2.ext.i18n'] ) #Enable translations. We're just using this for pluralization, not translating to different languages env.install_null_translations() template = env.get_template('copyedit/note.txt') graphics = [get_graphic_template_variables(path, i) for i, path in enumerate(paths)] note = template.render(graphics=graphics) # Gets rid of 'done' message at the end. # This suppresses output so only the graphic text # we want can be piped to the clipboard. output["status"] = False print note
def copy_template(cls, source, dest, context): from jinja2 import Environment, FileSystemLoader env = Environment(loader=FileSystemLoader('.')) with open(dest, 'w+') as out: out.write(env.get_template(source).render(context))