...
1Begin
2{% macro greetings(to, from=simple.name, name2="guest") %}
3Greetings to {{ to }} from {{ from }}. Howdy, {% if name2 == "guest" %}anonymous guest{% else %}{{ name2 }}{% endif %}!
4{% endmacro %}
5{{ greetings('') }}
6{{ greetings(10) }}
7{{ greetings("john") }}
8{{ greetings("john", "michelle") }}
9{{ greetings("john", "michelle", "johann") }}
10
11{% macro test2(loop, value) %}map[{{ loop.index0 }}] = {{ value }}{% endmacro %}
12{% for item in simple.misc_list %}
13{{ test2(loop, item) }}{% endfor %}
14
15issue #39 (deactivate auto-escape of macros)
16{% macro html_test(name) %}
17<p>Hello {{ name }}.</p>
18{% endmacro %}
19{{ html_test("Max") }}
20
21Importing macros
22{% from "macro.helper" import imported_macro, imported_macro as renamed_macro, imported_macro as html_test %}
23{{ imported_macro("User1") }}
24{{ renamed_macro("User2") }}
25{{ html_test("Max") }}
26
27Chaining macros{% from "macro2.helper" import greeter_macro %}
28{{ greeter_macro() }}
29End
View as plain text