http://jinja.pocoo.org/docs/dev/templates/
# jinja2 delimiters: {% %} - for expression: {{ }} - for outputting result
from jinja2 import Template
temp_str = "hello: {% for n in my_list %}{{n}} " "{% endfor %}"
t = Template(temp_str)
t.render(mylist = [3,6,9])
# Note:
1. In direct jinja2, the python variable is only passed through render method. Separate variable can be used in the jinja expression
2. In Flask, the flask method 'render_template' pass the variables to the jinja render
No comments:
Post a Comment