Skip to content
Myr

test.py

This file

Path

examples/basic/test.py

27 lines · 611 bytes · Python

Last changed by

moved example code aroundArmin Ronacherbefore adoption612b3a8

History of this file

Take it

moved example code aroundArmin Ronacherbefore adoption612b3a8

lines 1–27why, one step back
1from jinja2 import Environment
2from jinja2.loaders import DictLoader34env = Environment(loader=DictLoader({5'child.html': u'''\6{% extends master_layout or 'master.html' %}7{% include helpers = 'helpers.html' %}8{% macro get_the_answer() %}42{% endmacro %}9{% title = 'Hello World' %}10{% block body %}11 {{ get_the_answer() }}12 {{ helpers.conspirate() }}13{% endblock %}14''',15'master.html': u'''\16<!doctype html>17<title>{{ title }}</title>18{% block body %}{% endblock %}19''',20'helpers.html': u'''\21{% macro conspirate() %}23{% endmacro %}22'''23}))242526tmpl = env.get_template("child.html")27print tmpl.render()