fune/third_party/python/Jinja2/examples/basic/test.py
Chris H-C 329ab8a4a5 Bug 1635260 - Update vendored glean_parser to 1.28.0 r=janerik
Using ./mach vendor python glean_parser==1.28.0

(this is the latest version)

Differential Revision: https://phabricator.services.mozilla.com/D84746
2020-07-29 16:53:10 +00:00

31 lines
714 B
Python

from __future__ import print_function
from jinja2 import Environment
from jinja2.loaders import DictLoader
env = Environment(
loader=DictLoader(
{
"child.html": u"""\
{% extends master_layout or 'master.html' %}
{% include helpers = 'helpers.html' %}
{% macro get_the_answer() %}42{% endmacro %}
{% title = 'Hello World' %}
{% block body %}
{{ get_the_answer() }}
{{ helpers.conspirate() }}
{% endblock %}
""",
"master.html": u"""\
<!doctype html>
<title>{{ title }}</title>
{% block body %}{% endblock %}
""",
"helpers.html": u"""\
{% macro conspirate() %}23{% endmacro %}
""",
}
)
)
tmpl = env.get_template("child.html")
print(tmpl.render())