Bopytex/bopytex/worker/generate.py

14 lines
381 B
Python
Raw Normal View History

2022-04-10 13:50:58 +00:00
from jinja2.environment import Template
def generate(args, deps, output):
env = args["jinja2"]["environment"]
template = env.get_template(deps[0])
with open(output, "w") as out:
out.write(tpl2tex(template, metas=args))
yield f"GENERATE - {deps[0]} to {output}"
def tpl2tex(template: Template, metas: dict = {}) -> str:
return template.render(metas)