Created
August 24, 2016 15:33
-
-
Save l2ol33rt/1e6c58586d8eb0ae5c00182e2f70b935 to your computer and use it in GitHub Desktop.
Jinja DictLoader Example
This file contains 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
from jinja2 import Environment, DictLoader | |
template = """{% for key, value in _dict.iteritems() %} | |
this is the {{ key }} whose value is {{ value }} | |
{% endfor -%}""" | |
j2_env = Environment(loader=DictLoader({'sample.txt': template}), | |
trim_blocks=True) | |
print j2_env.get_template('sample.txt').render(_dict={'linux': 4.4, | |
'bsd': 10.3}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment