Skip to content

Instantly share code, notes, and snippets.

@svieira
Created June 16, 2014 13:42
Show Gist options
  • Save svieira/2838363f122fa44420b0 to your computer and use it in GitHub Desktop.
Save svieira/2838363f122fa44420b0 to your computer and use it in GitHub Desktop.
How to render a jinja template (standalone)
# 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