File: modglobals.py

package info (click to toggle)
jinja 1.2-3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,412 kB
  • ctags: 1,171
  • sloc: python: 6,438; ansic: 397; makefile: 74
file content (37 lines) | stat: -rw-r--r-- 692 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# test file for block super support
import jdebug
from jinja import Environment, DictLoader

env = Environment(loader=DictLoader({
    'a': '''\
<title>{{ title|e }}</title>
<body>
    {% block body %}Default{% endblock %}
</body>
''',
    'b': '''
{% set foo = 42 %}
''',
    'c': '''
{% extends 'a' %}
{% if true %}
    {% set title = "foo" %}
{% endif %}
{% include 'b' %}
{% include 'tools' %}
{% block body %}
    hehe, this comes from b: {{ foo }}

    Say hello to the former block content:
        {{ say_hello(super()) }}
{% endblock %}
''',
    'tools': '''
{% macro say_hello name -%}
    Hello {{ name }}!
{%- endmacro %}
'''
}))

tmpl = env.get_template('c')
print tmpl.render()