From 09b7cddcc2b1440406b591e705e260631269480d Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Thu, 8 Jun 2017 09:48:18 +0100 Subject: [PATCH] Add unified helper for jinja rendering --- md_pdf/build/jinja.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 md_pdf/build/jinja.py diff --git a/md_pdf/build/jinja.py b/md_pdf/build/jinja.py new file mode 100644 index 0000000..ed8f9cc --- /dev/null +++ b/md_pdf/build/jinja.py @@ -0,0 +1,15 @@ +from jinja2 import Environment + + +def render_content(content, context): + env = Environment( + trim_blocks=True, + lstrip_blocks=True, + extensions=[ + 'jinja2.ext.with_', + 'jinja2.ext.loopcontrols' + ] + + ) + template = env.from_string(content) + return template.render(**context)