• Home
  • Raw
  • Download

Lines Matching +full:set +full:- +full:env

13     def test_assigned_scoping(self, env):  argument
14 t = env.from_string(
16 {%- for item in (1, 2, 3, 4) -%}
18 {%- endfor %}
19 {{- item -}}
24 t = env.from_string(
26 {%- for item in (1, 2, 3, 4) -%}
28 {%- endfor %}
29 {%- set item = 42 %}
30 {{- item -}}
35 t = env.from_string(
37 {%- set item = 42 %}
38 {%- for item in (1, 2, 3, 4) -%}
40 {%- endfor %}
41 {{- item -}}
46 def test_closure_scoping(self, env): argument
47 t = env.from_string(
49 {%- set wrapper = "<FOO>" %}
50 {%- for item in (1, 2, 3, 4) %}
51 {%- macro wrapper() %}[{{ item }}]{% endmacro %}
52 {{- wrapper() }}
53 {%- endfor %}
54 {{- wrapper -}}
59 t = env.from_string(
61 {%- for item in (1, 2, 3, 4) %}
62 {%- macro wrapper() %}[{{ item }}]{% endmacro %}
63 {{- wrapper() }}
64 {%- endfor %}
65 {%- set wrapper = "<FOO>" %}
66 {{- wrapper -}}
71 t = env.from_string(
73 {%- for item in (1, 2, 3, 4) %}
74 {%- macro wrapper() %}[{{ item }}]{% endmacro %}
75 {{- wrapper() }}
76 {%- endfor %}
77 {{- wrapper -}}
84 def test_keyword_folding(self, env): argument
85 env = Environment()
86 env.filters["testing"] = lambda value, some: value + some
88 env.from_string("{{ 'test'|testing(some='stuff') }}").render()
92 def test_extends_output_bugs(self, env): argument
93 env = Environment(
97 t = env.from_string(
105 def test_urlize_filter_escaping(self, env): argument
106 tmpl = env.from_string('{{ "http://www.example.org/<foo"|urlize }}')
112 def test_loop_call_loop(self, env): argument
113 tmpl = env.from_string(
133 def test_weird_inline_comment(self, env): argument
134 env = Environment(line_statement_prefix="%")
137 env.from_string,
141 def test_old_macro_loop_scoping_bug(self, env): argument
142 tmpl = env.from_string(
148 def test_partial_conditional_assignments(self, env): argument
149 tmpl = env.from_string("{% if b %}{% set a = 42 %}{% endif %}{{ a }}")
153 def test_stacked_locals_scoping_bug(self, env): argument
154 env = Environment(line_statement_prefix="#")
155 t = env.from_string(
158 # set x = 1
162 # set x = x + 1
179 def test_stacked_locals_scoping_bug_twoframe(self, env): argument
182 {% set x = 1 %}
185 {% set x = 2 %}
194 def test_call_with_args(self, env): argument
196 """{% macro dump_users(users) -%}
198 {%- for user in users -%}
200 {%- endfor -%}
202 {%- endmacro -%}
204 {% call(user) dump_users(list_of_user) -%}
235 def test_empty_if_condition_fails(self, env): argument
242 def test_recursive_loop_compile(self, env): argument
272 def test_else_loop_bug(self, env): argument
284 def test_correct_prefix_loader_name(self, env): argument
285 env = Environment(loader=PrefixLoader({"foo": DictLoader({})}))
287 env.get_template("foo/bar.html")
291 def test_contextfunction_callable_classes(self, env): argument
306 env = Environment(
309 t = env.from_string('{% extends "main" %}{% set x %}42{% endset %}')
312 def test_nested_for_else(self, env): argument
313 tmpl = env.from_string(
320 def test_macro_var_bug(self, env): argument
321 tmpl = env.from_string(
323 {% set i = 1 %}
331 def test_macro_var_bug_advanced(self, env): argument
332 tmpl = env.from_string(
335 {% set i = 1 %}
345 env = Environment()
346 env.globals["get_int"] = lambda: 42
347 t = env.from_string(
349 {% macro test(a, b, c=get_int()) -%}
351 {%- endmacro %}
358 env = Environment(
363 assert env.from_string(template).render()
365 def test_macro_scoping(self, env): argument
366 tmpl = env.from_string(
368 {% set n=[1,2,3,4,5] %}
384 env = Environment(
388 {%- set foo = 'bar' -%}
389 {% include 'x.html' -%}
392 {%- set foo = 'bar' -%}
393 {% block test %}{% include 'x.html' %}{% endblock -%}
396 {%- set foo = 'bar' -%}
397 {% block test %}{% set foo = foo
398 %}{% include 'x.html' %}{% endblock -%}
405 a = env.get_template("a.html")
406 b = env.get_template("b.html")
407 c = env.get_template("c.html")
414 env = Environment(
419 "child.html": '{% extends "base.html" %}{% set var = 42 %}',
423 t = env.get_template("child.html")
426 def test_caller_scoping(self, env): argument
427 t = env.from_string(
429 {% macro detail(icon, value) -%}
430 {% if value -%}
431 <p><span class="fa fa-fw fa-{{ icon }}"></span>
432 {%- if caller is undefined -%}
434 {%- else -%}
436 {%- endif -%}</p>
437 {%- endif %}
438 {%- endmacro %}
441 {% macro link_detail(icon, value, href) -%}
442 {% call(value, href) detail(icon, value, href) -%}
444 {%- endcall %}
445 {%- endmacro %}
450 '<p><span class="fa fa-fw fa-circle"></span><a href="/">Index</a></p>'
453 def test_variable_reuse(self, env): argument
454 t = env.from_string("{% for x in x.y %}{{ x }}{% endfor %}")
457 t = env.from_string("{% for x in x.y %}{{ loop.index0 }}|{{ x }}{% endfor %}")
460 t = env.from_string("{% for x in x.y recursive %}{{ x }}{% endfor %}")
463 def test_double_caller(self, env): argument
464 t = env.from_string(
471 def test_double_caller_no_default(self, env): argument
473 env.from_string(
481 t = env.from_string(
491 def test_macro_blocks(self, env): argument
492 t = env.from_string(
497 def test_scoped_block(self, env): argument
498 t = env.from_string(
499 "{% set x = 1 %}{% with x = 2 %}{% block y scoped %}"
504 def test_recursive_loop_filter(self, env): argument
505 t = env.from_string(
507 <?xml version="1.0" encoding="UTF-8"?>
509 {%- for page in [site.root] if page.url != this recursive %}
511 {{- loop(page.children) }}
512 {%- endfor %}
522 '<?xml version="1.0" encoding="UTF-8"?>',
529 def test_empty_if(self, env): argument
530 t = env.from_string("{% if foo %}{% else %}42{% endif %}")
533 def test_subproperty_if(self, env): argument
534 t = env.from_string(
545 env = Environment(
549 "main": '{% set foo = "foo" %}{{ foo }}{% include "inc" %}',
553 assert env.get_template("main").render() == "foobar"
556 env = Environment(
564 assert env.get_template("main").render() == "123"
575 def test_custom_context(self, env): argument
585 env = MyEnvironment(loader=loader)
586 assert env.get_template("test").render(foobar="test") == "test"
588 def test_legacy_custom_context(self, env): argument
597 x = MyContext(env, parent={"bar": 23}, name="foo", blocks={})
603 def test_recursive_loop_bug(self, env): argument
604 tmpl = env.from_string(
605 "{%- for value in values recursive %}1{% else %}0{% endfor -%}"