Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > 165acbcc075de8309bb2fd18f8fd0952 > files > 96

python2-jinja2-2.11.3-1.mga7.noarch.rpm

from __future__ import print_function

from jinja2 import Environment

env = Environment(
    line_statement_prefix="%", variable_start_string="${", variable_end_string="}"
)
tmpl = env.from_string(
    """\
% macro foo()
    ${caller(42)}
% endmacro
<ul>
% for item in seq
    <li>${item}</li>
% endfor
</ul>
% call(var) foo()
    [${var}]
% endcall
% filter escape
    <hello world>
    % for item in [1, 2, 3]
      -  ${item}
    % endfor
% endfilter
"""
)
print(tmpl.render(seq=range(10)))