Created
June 16, 2014 13:42
-
-
Save svieira/2838363f122fa44420b0 to your computer and use it in GitHub Desktop.
How to render a jinja template (standalone)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Via http://pydanny.com/jinja2-quick-load-function.html | |
from jinja2 import FileSystemLoader, Environment | |
def render_from_template(directory, template_name, **kwargs): | |
loader = FileSystemLoader(directory) | |
env = Environment(loader=loader) | |
template = env.get_template(template_name) | |
return template.render(**kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment