Пример #1
0
 public function render($context)
 {
     $old_setting = $context->autoescape;
     $context->autoescape = $this->setting;
     $output = $this->nodelist->render($context);
     $context->autoescape = $old_setting;
     if ($this->setting) {
         return mark_safe($output);
     } else {
         return $output;
     }
 }
Пример #2
0
 public function super()
 {
     $render_context = $this->context->render_context;
     if (isset($render_context[BLOCK_CONTEXT_KEY]) && $render_context[BLOCK_CONTEXT_KEY]->getBlock($this->name) !== null) {
         return mark_safe($this->render($this->context));
     }
     return '';
 }
Пример #3
0
 /**
  * @param Context $context
  * @param bool $ignore_failures
  *
  * @return mixed
  */
 public function resolve($context, $ignore_failures = False)
 {
     if ($this->var instanceof Variable) {
         try {
             $obj = $this->var->resolve($context);
         } catch (VariableDoesNotExist $e) {
             if ($ignore_failures) {
                 $obj = null;
             } else {
                 if (Dja::getSetting('TEMPLATE_STRING_IF_INVALID')) {
                     if (DjaBase::$invalid_var_format_string === null) {
                         DjaBase::$invalid_var_format_string = strpos(Dja::getSetting('TEMPLATE_STRING_IF_INVALID'), '%s') !== False;
                     }
                     if (DjaBase::$invalid_var_format_string) {
                         return sprintf(Dja::getSetting('TEMPLATE_STRING_IF_INVALID'), $this->var);
                     }
                     return Dja::getSetting('TEMPLATE_STRING_IF_INVALID');
                 } else {
                     $obj = Dja::getSetting('TEMPLATE_STRING_IF_INVALID');
                 }
             }
         }
     } else {
         $obj = $this->var;
     }
     foreach ($this->filters as $filter) {
         list($func, $args, $n_) = $filter;
         $arg_vals = array();
         foreach ($args as $arg_data) {
             /** @var $arg Variable|string */
             list($lookup, $arg) = $arg_data;
             if (!$lookup) {
                 $arg_vals[] = mark_safe($arg);
             } else {
                 $arg_vals[] = $arg->resolve($context);
             }
         }
         if (py_getattr($func, 'expects_localtime', False)) {
             $obj = localtime($obj, $context->use_tz);
         }
         $func_ = $func->closure;
         if (py_getattr($func, 'needs_autoescape', False)) {
             $new_obj = call_user_func_array($func_, array_merge(array($obj, $context->autoescape), $arg_vals));
         } else {
             $new_obj = call_user_func_array($func_, array_merge(array($obj), $arg_vals));
         }
         if (py_getattr($func, 'is_safe', False) && $obj instanceof SafeData) {
             $obj = mark_safe($new_obj);
         } else {
             if ($obj instanceof EscapeData) {
                 $obj = mark_for_escaping($new_obj);
             } else {
                 $obj = $new_obj;
             }
         }
     }
     return $obj;
 }
Пример #4
0
function escape($html)
{
    $html = str_replace('&', '&', $html);
    $html = str_replace('<', '&lt;', $html);
    $html = str_replace('>', '&gt;', $html);
    $html = str_replace('"', '&quot;', $html);
    $html = str_replace("'", '&#39;', $html);
    return mark_safe($html);
}
Пример #5
0
 public function __invoke()
 {
     return mark_safe('you &gt; me');
 }
Пример #6
0
 private static function getTemplateTests()
 {
     // SYNTAX --
     // 'template_name': ('template contents', 'context dict', 'expected string output' or Exception class)
     // TODO For ssi: $basedir = dirname(__FILE__);
     $tests = array('basic-syntax01' => array('something cool', array(), 'something cool'), 'basic-syntax02' => array('{{ headline }}', array('headline' => 'Success'), 'Success'), 'basic-syntax03' => array("{{ first }} --- {{ second }}", array("first" => 1, "second" => 2), "1 --- 2"), 'basic-syntax04' => array("as{{ missing }}df", array(), array("asdf", "asINVALIDdf")), 'basic-syntax06' => array("{{ multi word variable }}", array(), 'TemplateSyntaxError'), 'basic-syntax07' => array("{{ }}", array(), 'TemplateSyntaxError'), 'basic-syntax08' => array("{{        }}", array(), 'TemplateSyntaxError'), 'basic-syntax09' => array("{{ var.method }}", array("var" => new SomeClass()), "SomeClass.method"), 'basic-syntax10' => array("{{ var.otherclass.method }}", array("var" => new SomeClass()), "OtherClass.method"), 'basic-syntax11' => array("{{ var.blech }}", array("var" => new SomeClass()), array("", "INVALID")), 'basic-syntax12' => array("{{ var.__dict__ }}", array("var" => new SomeClass()), 'TemplateSyntaxError'), 'basic-syntax13' => array("{{ va>r }}", array(), 'TemplateSyntaxError'), 'basic-syntax14' => array("{{ (var.r) }}", array(), 'TemplateSyntaxError'), 'basic-syntax15' => array("{{ sp%am }}", array(), 'TemplateSyntaxError'), 'basic-syntax16' => array("{{ eggs! }}", array(), 'TemplateSyntaxError'), 'basic-syntax17' => array("{{ moo? }}", array(), 'TemplateSyntaxError'), 'basic-syntax18' => array("{{ foo.bar }}", array("foo" => array("bar" => "baz")), "baz"), 'basic-syntax19' => array("{{ foo.spam }}", array("foo" => array("bar" => "baz")), array("", "INVALID")), 'basic-syntax20' => array("{{ var.method2 }}", array("var" => new SomeClass()), array("", "INVALID")), 'basic-syntax21' => array("a {{ moo %} b", array(), "a {{ moo %} b"), 'basic-syntax22' => array("{{ moo #}", array(), "{{ moo #}"), 'basic-syntax23' => array("{{ moo #} {{ cow }}", array("cow" => "cow"), 'TemplateSyntaxError'), 'basic-syntax24' => array("{{ moo\n }}", array(), "{{ moo\n }}"), 'basic-syntax25' => array('{{ "fred" }}', array(), "fred"), 'basic-syntax26' => array('{{ "\\"fred\\"" }}', array(), "\"fred\""), 'basic-syntax27' => array('{{ _("\\"fred\\"") }}', array(), "\"fred\""), 'basic-syntax28' => array("{{ a.b }}", array('a' => new SilentGetItemClass()), array('', 'INVALID')), 'basic-syntax29' => array("{{ a.b }}", array('a' => new SilentAttrClass()), array('', 'INVALID')), 'basic-syntax30' => array("{{ 1.2.3 }}", array("1" => array("2" => array("3" => "d"))), "d"), 'basic-syntax31' => array("{{ 1.2.3 }}", array("1" => array("2" => array("a", "b", "c", "d"))), "d"), 'basic-syntax32' => array("{{ 1.2.3 }}", array("1" => array(array("x", "x", "x", "x"), array("y", "y", "y", "y"), array("a", "b", "c", "d"))), "d"), 'basic-syntax33' => array("{{ 1.2.3 }}", array("1" => array("xxxx", "yyyy", "abcd")), "d"), 'basic-syntax34' => array("{{ 1.2.3 }}", array("1" => array(array("x" => "x"), array("y" => "y"), array("z" => "z", "3" => "d"))), "d"), 'basic-syntax35' => array("{{ 1 }}", array("1" => "abc"), "1"), 'basic-syntax36' => array("{{ 1.2 }}", array("1" => "abc"), "1.2"), 'basic-syntax37' => array('{{ callable }}', array("callable" => function () {
         return "foo bar";
     }), "foo bar"), 'basic-syntax38' => array('{{ var.callable }}', array("var" => array("callable" => function () {
         return "foo bar";
     })), "foo bar"), 'list-index01' => array("{{ var.1 }}", array("var" => array("first item", "second item")), "second item"), 'list-index02' => array("{{ var.5 }}", array("var" => array("first item", "second item")), array("", "INVALID")), 'list-index03' => array("{{ var.1 }}", array("var" => null), array("", "INVALID")), 'list-index04' => array("{{ var.1 }}", array("var" => array()), array("", "INVALID")), 'list-index05' => array("{{ var.1 }}", array("var" => array('1' => "hello")), "hello"), 'list-index06' => array("{{ var.1 }}", array("var" => array(1 => "hello")), "hello"), 'filter-syntax01' => array("{{ var|upper }}", array("var" => "Django is the greatest!"), "DJANGO IS THE GREATEST!"), 'filter-syntax02' => array("{{ var|upper|lower }}", array("var" => "Django is the greatest!"), "django is the greatest!"), 'filter-syntax03' => array("{{ var |upper }}", array(), 'TemplateSyntaxError'), 'filter-syntax04' => array("{{ var| upper }}", array(), 'TemplateSyntaxError'), 'filter-syntax05' => array("{{ var|does_not_exist }}", array(), 'TemplateSyntaxError'), 'filter-syntax06' => array("{{ var|fil(ter) }}", array(), 'TemplateSyntaxError'), 'filter-syntax07' => array("{% nothing_to_see_here %}", array(), 'TemplateSyntaxError'), 'filter-syntax08' => array("{% %}", array(), 'TemplateSyntaxError'), 'filter-syntax09' => array('{{ var|removetags:"b i"|upper|lower }}', array("var" => "<b><i>Yes</i></b>"), "yes"), 'filter-syntax10' => array('{{ var|default_if_none:" endquote\\" hah" }}', array("var" => null), ' endquote" hah'), 'filter-syntax11' => array('{{ var|default_if_none:var2 }}', array("var" => null, "var2" => "happy"), 'happy'), 'filter-syntax12' => array('{{ var|yesno:"yup,nup,mup" }} {{ var|yesno }}', array("var" => True), 'yup yes'), 'filter-syntax13' => array('1{{ var.method3 }}2', array("var" => new SomeClass()), array("12", "1INVALID2")), 'filter-syntax14' => array('1{{ var.method4 }}2', array("var" => new SomeClass()), array('SomeOtherException', 'SomeOtherException')), 'filter-syntax15' => array('{{ var|default_if_none:"foo\\bar" }}', array("var" => null), 'foo\\bar'), 'filter-syntax16' => array('{{ var|default_if_none:"foo\\now" }}', array("var" => null), 'foo\\now'), 'filter-syntax17' => array('{{ var|join:"" }}', array('var' => array('a', 'b', 'c')), 'abc'), 'filter-syntax19' => array('{{ var|truncatewords:1 }}', array("var" => "hello world"), "hello ..."), 'filter-syntax20' => array('{{ ""|default_if_none:"was none" }}', array(), ""), 'filter-syntax21' => array('1{{ var.silent_fail_key }}2', array("var" => new SomeClass()), array("12", "1INVALID2")), 'filter-syntax22' => array('1{{ var.silent_fail_attribute }}2', array("var" => new SomeClass()), array("12", "1INVALID2")), 'filter-syntax23' => array('1{{ var.noisy_fail_key }}2', array("var" => new SomeClass()), array('SomeOtherException', 'SomeOtherException')), 'filter-syntax24' => array('1{{ var.noisy_fail_attribute }}2', array("var" => new SomeClass()), array('SomeOtherException', 'SomeOtherException')), 'comment-syntax01' => array("{# this is hidden #}hello", array(), "hello"), 'comment-syntax02' => array("{# this is hidden #}hello{# foo #}", array(), "hello"), 'comment-syntax03' => array("foo{#  {% if %}  #}", array(), "foo"), 'comment-syntax04' => array("foo{#  {% endblock %}  #}", array(), "foo"), 'comment-syntax05' => array("foo{#  {% somerandomtag %}  #}", array(), "foo"), 'comment-syntax06' => array("foo{# {% #}", array(), "foo"), 'comment-syntax07' => array("foo{# %} #}", array(), "foo"), 'comment-syntax08' => array("foo{# %} #}bar", array(), "foobar"), 'comment-syntax09' => array("foo{# {{ #}", array(), "foo"), 'comment-syntax10' => array("foo{# }} #}", array(), "foo"), 'comment-syntax11' => array("foo{# { #}", array(), "foo"), 'comment-syntax12' => array("foo{# } #}", array(), "foo"), 'comment-tag01' => array("{% comment %}this is hidden{% endcomment %}hello", array(), "hello"), 'comment-tag02' => array("{% comment %}this is hidden{% endcomment %}hello{% comment %}foo{% endcomment %}", array(), "hello"), 'comment-tag03' => array("foo{% comment %} {% if %} {% endcomment %}", array(), "foo"), 'comment-tag04' => array("foo{% comment %} {% endblock %} {% endcomment %}", array(), "foo"), 'comment-tag05' => array("foo{% comment %} {% somerandomtag %} {% endcomment %}", array(), "foo"), 'cycle01' => array('{% cycle a %}', array(), 'TemplateSyntaxError'), 'cycle02' => array('{% cycle a,b,c as abc %}{% cycle abc %}', array(), 'ab'), 'cycle03' => array('{% cycle a,b,c as abc %}{% cycle abc %}{% cycle abc %}', array(), 'abc'), 'cycle04' => array('{% cycle a,b,c as abc %}{% cycle abc %}{% cycle abc %}{% cycle abc %}', array(), 'abca'), 'cycle05' => array('{% cycle %}', array(), 'TemplateSyntaxError'), 'cycle06' => array('{% cycle a %}', array(), 'TemplateSyntaxError'), 'cycle07' => array('{% cycle a,b,c as foo %}{% cycle bar %}', array(), 'TemplateSyntaxError'), 'cycle08' => array('{% cycle a,b,c as foo %}{% cycle foo %}{{ foo }}{{ foo }}{% cycle foo %}{{ foo }}', array(), 'abbbcc'), 'cycle09' => array("{% for i in test %}{% cycle a,b %}{{ i }},{% endfor %}", array('test' => array(0, 1, 2, 3, 4)), 'a0,b1,a2,b3,a4,'), 'cycle10' => array("{% cycle 'a' 'b' 'c' as abc %}{% cycle abc %}", array(), 'ab'), 'cycle11' => array("{% cycle 'a' 'b' 'c' as abc %}{% cycle abc %}{% cycle abc %}", array(), 'abc'), 'cycle12' => array("{% cycle 'a' 'b' 'c' as abc %}{% cycle abc %}{% cycle abc %}{% cycle abc %}", array(), 'abca'), 'cycle13' => array("{% for i in test %}{% cycle 'a' 'b' %}{{ i }},{% endfor %}", array('test' => array(0, 1, 2, 3, 4)), 'a0,b1,a2,b3,a4,'), 'cycle14' => array("{% cycle one two as foo %}{% cycle foo %}", array('one' => '1', 'two' => '2'), '12'), 'cycle15' => array("{% for i in test %}{% cycle aye bee %}{{ i }},{% endfor %}", array('test' => array(0, 1, 2, 3, 4), 'aye' => 'a', 'bee' => 'b'), 'a0,b1,a2,b3,a4,'), 'cycle16' => array("{% cycle one|lower two as foo %}{% cycle foo %}", array('one' => 'A', 'two' => '2'), 'a2'), 'cycle17' => array("{% cycle 'a' 'b' 'c' as abc silent %}{% cycle abc %}{% cycle abc %}{% cycle abc %}{% cycle abc %}", array(), ""), 'cycle18' => array("{% cycle 'a' 'b' 'c' as foo invalid_flag %}", array(), 'TemplateSyntaxError'), 'cycle19' => array("{% cycle 'a' 'b' as silent %}{% cycle silent %}", array(), "ab"), 'cycle20' => array("{% cycle one two as foo %} &amp; {% cycle foo %}", array('one' => 'A & B', 'two' => 'C & D'), "A & B &amp; C & D"), 'cycle21' => array("{% filter force_escape %}{% cycle one two as foo %} & {% cycle foo %}{% endfilter %}", array('one' => 'A & B', 'two' => 'C & D'), "A &amp; B &amp; C &amp; D"), 'cycle22' => array("{% for x in values %}{% cycle 'a' 'b' 'c' as abc silent %}{{ x }}{% endfor %}", array('values' => array(1, 2, 3, 4)), "1234"), 'cycle23' => array("{% for x in values %}{% cycle 'a' 'b' 'c' as abc silent %}{{ abc }}{{ x }}{% endfor %}", array('values' => array(1, 2, 3, 4)), "a1b2c3a4"), 'included-cycle' => array('{{ abc }}', array('abc' => 'xxx'), 'xxx'), 'cycle24' => array("{% for x in values %}{% cycle 'a' 'b' 'c' as abc silent %}{% include 'included-cycle' %}{% endfor %}", array('values' => array(1, 2, 3, 4)), "abca"), 'exception01' => array("{% extends 'nonexistent' %}", array(), array('TemplateDoesNotExist', 'TemplateDoesNotExist')), 'exception02' => array("{% extends nonexistent %}", array(), array('TemplateSyntaxError', 'TemplateDoesNotExist')), 'exception03' => array("{% extends 'inheritance01' %}{% block first %}2{% endblock %}{% extends 'inheritance16' %}", array(), 'TemplateSyntaxError'), 'exception04' => array("{% extends 'inheritance17' %}{% block first %}{% echo 400 %}5678{% endblock %}", array(), 'TemplateSyntaxError'), 'filter01' => array('{% filter upper %}{% endfilter %}', array(), ''), 'filter02' => array('{% filter upper %}django{% endfilter %}', array(), 'DJANGO'), 'filter03' => array('{% filter upper|lower %}django{% endfilter %}', array(), 'django'), 'filter04' => array('{% filter cut:remove %}djangospam{% endfilter %}', array('remove' => 'spam'), 'django'), 'firstof01' => array('{% firstof a b c %}', array('a' => 0, 'b' => 0, 'c' => 0), ''), 'firstof02' => array('{% firstof a b c %}', array('a' => 1, 'b' => 0, 'c' => 0), '1'), 'firstof03' => array('{% firstof a b c %}', array('a' => 0, 'b' => 2, 'c' => 0), '2'), 'firstof04' => array('{% firstof a b c %}', array('a' => 0, 'b' => 0, 'c' => 3), '3'), 'firstof05' => array('{% firstof a b c %}', array('a' => 1, 'b' => 2, 'c' => 3), '1'), 'firstof06' => array('{% firstof a b c %}', array('b' => 0, 'c' => 3), '3'), 'firstof07' => array('{% firstof a b "c" %}', array('a' => 0), 'c'), 'firstof08' => array('{% firstof a b "c and d" %}', array('a' => 0, 'b' => 0), 'c and d'), 'firstof09' => array('{% firstof %}', array(), 'TemplateSyntaxError'), 'firstof10' => array('{% firstof a %}', array('a' => '<'), '<'), 'for-tag01' => array("{% for val in values %}{{ val }}{% endfor %}", array("values" => array(1, 2, 3)), "123"), 'for-tag02' => array("{% for val in values reversed %}{{ val }}{% endfor %}", array("values" => array(1, 2, 3)), "321"), 'for-tag-vars01' => array("{% for val in values %}{{ forloop.counter }}{% endfor %}", array("values" => array(6, 6, 6)), "123"), 'for-tag-vars02' => array("{% for val in values %}{{ forloop.counter0 }}{% endfor %}", array("values" => array(6, 6, 6)), "012"), 'for-tag-vars03' => array("{% for val in values %}{{ forloop.revcounter }}{% endfor %}", array("values" => array(6, 6, 6)), "321"), 'for-tag-vars04' => array("{% for val in values %}{{ forloop.revcounter0 }}{% endfor %}", array("values" => array(6, 6, 6)), "210"), 'for-tag-vars05' => array("{% for val in values %}{% if forloop.first %}f{% else %}x{% endif %}{% endfor %}", array("values" => array(6, 6, 6)), "fxx"), 'for-tag-vars06' => array("{% for val in values %}{% if forloop.last %}l{% else %}x{% endif %}{% endfor %}", array("values" => array(6, 6, 6)), "xxl"), 'for-tag-unpack01' => array("{% for key,value in items %}{{ key }}:{{ value }}/{% endfor %}", array("items" => array(array('one', 1), array('two', 2))), "one:1/two:2/"), 'for-tag-unpack03' => array("{% for key, value in items %}{{ key }}:{{ value }}/{% endfor %}", array("items" => array(array('one', 1), array('two', 2))), "one:1/two:2/"), 'for-tag-unpack04' => array("{% for key , value in items %}{{ key }}:{{ value }}/{% endfor %}", array("items" => array(array('one', 1), array('two', 2))), "one:1/two:2/"), 'for-tag-unpack05' => array("{% for key ,value in items %}{{ key }}:{{ value }}/{% endfor %}", array("items" => array(array('one', 1), array('two', 2))), "one:1/two:2/"), 'for-tag-unpack06' => array("{% for key value in items %}{{ key }}:{{ value }}/{% endfor %}", array("items" => array(array('one', 1), array('two', 2))), 'TemplateSyntaxError'), 'for-tag-unpack07' => array("{% for key,,value in items %}{{ key }}:{{ value }}/{% endfor %}", array("items" => array(array('one', 1), array('two', 2))), 'TemplateSyntaxError'), 'for-tag-unpack08' => array("{% for key,value, in items %}{{ key }}:{{ value }}/{% endfor %}", array("items" => array(array('one', 1), array('two', 2))), 'TemplateSyntaxError'), 'for-tag-unpack09' => array("{% for val in items %}{{ val.0 }}:{{ val.1 }}/{% endfor %}", array("items" => array(array('one', 1), array('two', 2))), "one:1/two:2/"), 'for-tag-unpack10' => array("{% for x,y in items %}{{ x }}:{{ y }}/{% endfor %}", array("items" => array(array('one', 1, 'carrot'), array('two', 2, 'orange'))), "one:1/two:2/"), 'for-tag-unpack11' => array("{% for x,y,z in items %}{{ x }}:{{ y }},{{ z }}/{% endfor %}", array("items" => array(array('one', 1), array('two', 2))), array("one:1,/two:2,/", "one:1,INVALID/two:2,INVALID/")), 'for-tag-unpack12' => array("{% for x,y,z in items %}{{ x }}:{{ y }},{{ z }}/{% endfor %}", array("items" => array(array('one', 1, 'carrot'), array('two', 2))), array("one:1,carrot/two:2,/", "one:1,carrot/two:2,INVALID/")), 'for-tag-unpack13' => array("{% for x,y,z in items %}{{ x }}:{{ y }},{{ z }}/{% endfor %}", array("items" => array(array('one', 1, 'carrot'), array('two', 2, 'cheese'))), array("one:1,carrot/two:2,cheese/", "one:1,carrot/two:2,cheese/")), 'for-tag-unpack14' => array("{% for x,y in items %}{{ x }}:{{ y }}/{% endfor %}", array("items" => array(1, 2)), array(":/:/", "INVALID:INVALID/INVALID:INVALID/")), 'for-tag-empty01' => array("{% for val in values %}{{ val }}{% empty %}empty text{% endfor %}", array("values" => array(1, 2, 3)), "123"), 'for-tag-empty02' => array("{% for val in values %}{{ val }}{% empty %}values array empty{% endfor %}", array("values" => array()), "values array empty"), 'for-tag-empty03' => array("{% for val in values %}{{ val }}{% empty %}values array not found{% endfor %}", array(), "values array not found"), 'if-tag01' => array("{% if foo %}yes{% else %}no{% endif %}", array("foo" => True), "yes"), 'if-tag02' => array("{% if foo %}yes{% else %}no{% endif %}", array("foo" => False), "no"), 'if-tag03' => array("{% if foo %}yes{% else %}no{% endif %}", array(), "no"), 'if-tag04' => array("{% if foo %}foo{% elif bar %}bar{% endif %}", array('foo' => True), "foo"), 'if-tag05' => array("{% if foo %}foo{% elif bar %}bar{% endif %}", array('bar' => True), "bar"), 'if-tag06' => array("{% if foo %}foo{% elif bar %}bar{% endif %}", array(), ""), 'if-tag07' => array("{% if foo %}foo{% elif bar %}bar{% else %}nothing{% endif %}", array('foo' => True), "foo"), 'if-tag08' => array("{% if foo %}foo{% elif bar %}bar{% else %}nothing{% endif %}", array('bar' => True), "bar"), 'if-tag09' => array("{% if foo %}foo{% elif bar %}bar{% else %}nothing{% endif %}", array(), "nothing"), 'if-tag10' => array("{% if foo %}foo{% elif bar %}bar{% elif baz %}baz{% else %}nothing{% endif %}", array('foo' => True), "foo"), 'if-tag11' => array("{% if foo %}foo{% elif bar %}bar{% elif baz %}baz{% else %}nothing{% endif %}", array('bar' => True), "bar"), 'if-tag12' => array("{% if foo %}foo{% elif bar %}bar{% elif baz %}baz{% else %}nothing{% endif %}", array('baz' => True), "baz"), 'if-tag13' => array("{% if foo %}foo{% elif bar %}bar{% elif baz %}baz{% else %}nothing{% endif %}", array(), "nothing"), 'if-tag-filter01' => array("{% if foo|length == 5 %}yes{% else %}no{% endif %}", array('foo' => 'abcde'), "yes"), 'if-tag-filter02' => array("{% if foo|upper == 'ABC' %}yes{% else %}no{% endif %}", array(), "no"), 'if-tag-eq01' => array("{% if foo == bar %}yes{% else %}no{% endif %}", array(), "yes"), 'if-tag-eq02' => array("{% if foo == bar %}yes{% else %}no{% endif %}", array('foo' => 1), "no"), 'if-tag-eq03' => array("{% if foo == bar %}yes{% else %}no{% endif %}", array('foo' => 1, 'bar' => 1), "yes"), 'if-tag-eq04' => array("{% if foo == bar %}yes{% else %}no{% endif %}", array('foo' => 1, 'bar' => 2), "no"), 'if-tag-eq05' => array("{% if foo == '' %}yes{% else %}no{% endif %}", array(), "no"), 'if-tag-gt-01' => array("{% if 2 > 1 %}yes{% else %}no{% endif %}", array(), "yes"), 'if-tag-gt-02' => array("{% if 1 > 1 %}yes{% else %}no{% endif %}", array(), "no"), 'if-tag-gte-01' => array("{% if 1 >= 1 %}yes{% else %}no{% endif %}", array(), "yes"), 'if-tag-gte-02' => array("{% if 1 >= 2 %}yes{% else %}no{% endif %}", array(), "no"), 'if-tag-lt-01' => array("{% if 1 < 2 %}yes{% else %}no{% endif %}", array(), "yes"), 'if-tag-lt-02' => array("{% if 1 < 1 %}yes{% else %}no{% endif %}", array(), "no"), 'if-tag-lte-01' => array("{% if 1 <= 1 %}yes{% else %}no{% endif %}", array(), "yes"), 'if-tag-lte-02' => array("{% if 2 <= 1 %}yes{% else %}no{% endif %}", array(), "no"), 'if-tag-in-01' => array("{% if 1 in x %}yes{% else %}no{% endif %}", array('x' => array(1)), "yes"), 'if-tag-in-02' => array("{% if 2 in x %}yes{% else %}no{% endif %}", array('x' => array(1)), "no"), 'if-tag-not-in-01' => array("{% if 1 not in x %}yes{% else %}no{% endif %}", array('x' => array(1)), "no"), 'if-tag-not-in-02' => array("{% if 2 not in x %}yes{% else %}no{% endif %}", array('x' => array(1)), "yes"), 'if-tag-and01' => array("{% if foo and bar %}yes{% else %}no{% endif %}", array('foo' => True, 'bar' => True), 'yes'), 'if-tag-and02' => array("{% if foo and bar %}yes{% else %}no{% endif %}", array('foo' => True, 'bar' => False), 'no'), 'if-tag-and03' => array("{% if foo and bar %}yes{% else %}no{% endif %}", array('foo' => False, 'bar' => True), 'no'), 'if-tag-and04' => array("{% if foo and bar %}yes{% else %}no{% endif %}", array('foo' => False, 'bar' => False), 'no'), 'if-tag-and05' => array("{% if foo and bar %}yes{% else %}no{% endif %}", array('foo' => False), 'no'), 'if-tag-and06' => array("{% if foo and bar %}yes{% else %}no{% endif %}", array('bar' => False), 'no'), 'if-tag-and07' => array("{% if foo and bar %}yes{% else %}no{% endif %}", array('foo' => True), 'no'), 'if-tag-and08' => array("{% if foo and bar %}yes{% else %}no{% endif %}", array('bar' => True), 'no'), 'if-tag-or01' => array("{% if foo or bar %}yes{% else %}no{% endif %}", array('foo' => True, 'bar' => True), 'yes'), 'if-tag-or02' => array("{% if foo or bar %}yes{% else %}no{% endif %}", array('foo' => True, 'bar' => False), 'yes'), 'if-tag-or03' => array("{% if foo or bar %}yes{% else %}no{% endif %}", array('foo' => False, 'bar' => True), 'yes'), 'if-tag-or04' => array("{% if foo or bar %}yes{% else %}no{% endif %}", array('foo' => False, 'bar' => False), 'no'), 'if-tag-or05' => array("{% if foo or bar %}yes{% else %}no{% endif %}", array('foo' => False), 'no'), 'if-tag-or06' => array("{% if foo or bar %}yes{% else %}no{% endif %}", array('bar' => False), 'no'), 'if-tag-or07' => array("{% if foo or bar %}yes{% else %}no{% endif %}", array('foo' => True), 'yes'), 'if-tag-or08' => array("{% if foo or bar %}yes{% else %}no{% endif %}", array('bar' => True), 'yes'), 'if-tag-or09' => array("{% if foo or bar or baz %}yes{% else %}no{% endif %}", array('baz' => True), 'yes'), 'if-tag-not01' => array("{% if not foo %}no{% else %}yes{% endif %}", array('foo' => True), 'yes'), 'if-tag-not02' => array("{% if not not foo %}no{% else %}yes{% endif %}", array('foo' => True), 'no'), 'if-tag-not06' => array("{% if foo and not bar %}yes{% else %}no{% endif %}", array(), 'no'), 'if-tag-not07' => array("{% if foo and not bar %}yes{% else %}no{% endif %}", array('foo' => True, 'bar' => True), 'no'), 'if-tag-not08' => array("{% if foo and not bar %}yes{% else %}no{% endif %}", array('foo' => True, 'bar' => False), 'yes'), 'if-tag-not09' => array("{% if foo and not bar %}yes{% else %}no{% endif %}", array('foo' => False, 'bar' => True), 'no'), 'if-tag-not10' => array("{% if foo and not bar %}yes{% else %}no{% endif %}", array('foo' => False, 'bar' => False), 'no'), 'if-tag-not11' => array("{% if not foo and bar %}yes{% else %}no{% endif %}", array(), 'no'), 'if-tag-not12' => array("{% if not foo and bar %}yes{% else %}no{% endif %}", array('foo' => True, 'bar' => True), 'no'), 'if-tag-not13' => array("{% if not foo and bar %}yes{% else %}no{% endif %}", array('foo' => True, 'bar' => False), 'no'), 'if-tag-not14' => array("{% if not foo and bar %}yes{% else %}no{% endif %}", array('foo' => False, 'bar' => True), 'yes'), 'if-tag-not15' => array("{% if not foo and bar %}yes{% else %}no{% endif %}", array('foo' => False, 'bar' => False), 'no'), 'if-tag-not16' => array("{% if foo or not bar %}yes{% else %}no{% endif %}", array(), 'yes'), 'if-tag-not17' => array("{% if foo or not bar %}yes{% else %}no{% endif %}", array('foo' => True, 'bar' => True), 'yes'), 'if-tag-not18' => array("{% if foo or not bar %}yes{% else %}no{% endif %}", array('foo' => True, 'bar' => False), 'yes'), 'if-tag-not19' => array("{% if foo or not bar %}yes{% else %}no{% endif %}", array('foo' => False, 'bar' => True), 'no'), 'if-tag-not20' => array("{% if foo or not bar %}yes{% else %}no{% endif %}", array('foo' => False, 'bar' => False), 'yes'), 'if-tag-not21' => array("{% if not foo or bar %}yes{% else %}no{% endif %}", array(), 'yes'), 'if-tag-not22' => array("{% if not foo or bar %}yes{% else %}no{% endif %}", array('foo' => True, 'bar' => True), 'yes'), 'if-tag-not23' => array("{% if not foo or bar %}yes{% else %}no{% endif %}", array('foo' => True, 'bar' => False), 'no'), 'if-tag-not24' => array("{% if not foo or bar %}yes{% else %}no{% endif %}", array('foo' => False, 'bar' => True), 'yes'), 'if-tag-not25' => array("{% if not foo or bar %}yes{% else %}no{% endif %}", array('foo' => False, 'bar' => False), 'yes'), 'if-tag-not26' => array("{% if not foo and not bar %}yes{% else %}no{% endif %}", array(), 'yes'), 'if-tag-not27' => array("{% if not foo and not bar %}yes{% else %}no{% endif %}", array('foo' => True, 'bar' => True), 'no'), 'if-tag-not28' => array("{% if not foo and not bar %}yes{% else %}no{% endif %}", array('foo' => True, 'bar' => False), 'no'), 'if-tag-not29' => array("{% if not foo and not bar %}yes{% else %}no{% endif %}", array('foo' => False, 'bar' => True), 'no'), 'if-tag-not30' => array("{% if not foo and not bar %}yes{% else %}no{% endif %}", array('foo' => False, 'bar' => False), 'yes'), 'if-tag-not31' => array("{% if not foo or not bar %}yes{% else %}no{% endif %}", array(), 'yes'), 'if-tag-not32' => array("{% if not foo or not bar %}yes{% else %}no{% endif %}", array('foo' => True, 'bar' => True), 'no'), 'if-tag-not33' => array("{% if not foo or not bar %}yes{% else %}no{% endif %}", array('foo' => True, 'bar' => False), 'yes'), 'if-tag-not34' => array("{% if not foo or not bar %}yes{% else %}no{% endif %}", array('foo' => False, 'bar' => True), 'yes'), 'if-tag-not35' => array("{% if not foo or not bar %}yes{% else %}no{% endif %}", array('foo' => False, 'bar' => False), 'yes'), 'if-tag-error01' => array("{% if %}yes{% endif %}", array(), 'TemplateSyntaxError'), 'if-tag-error02' => array("{% if foo and %}yes{% else %}no{% endif %}", array('foo' => True), 'TemplateSyntaxError'), 'if-tag-error03' => array("{% if foo or %}yes{% else %}no{% endif %}", array('foo' => True), 'TemplateSyntaxError'), 'if-tag-error04' => array("{% if not foo and %}yes{% else %}no{% endif %}", array('foo' => True), 'TemplateSyntaxError'), 'if-tag-error05' => array("{% if not foo or %}yes{% else %}no{% endif %}", array('foo' => True), 'TemplateSyntaxError'), 'if-tag-error06' => array("{% if abc def %}yes{% endif %}", array(), 'TemplateSyntaxError'), 'if-tag-error07' => array("{% if not %}yes{% endif %}", array(), 'TemplateSyntaxError'), 'if-tag-error08' => array("{% if and %}yes{% endif %}", array(), 'TemplateSyntaxError'), 'if-tag-error09' => array("{% if or %}yes{% endif %}", array(), 'TemplateSyntaxError'), 'if-tag-error10' => array("{% if == %}yes{% endif %}", array(), 'TemplateSyntaxError'), 'if-tag-error11' => array("{% if 1 == %}yes{% endif %}", array(), 'TemplateSyntaxError'), 'if-tag-error12' => array("{% if a not b %}yes{% endif %}", array(), 'TemplateSyntaxError'), 'if-tag-shortcircuit01' => array('{% if x.is_true or x.is_bad %}yes{% else %}no{% endif %}', array('x' => new TestObj()), "yes"), 'if-tag-shortcircuit02' => array('{% if x.is_false and x.is_bad %}yes{% else %}no{% endif %}', array('x' => new TestObj()), "no"), 'if-tag-badarg01' => array("{% if x|default_if_none:y %}yes{% endif %}", array(), ''), 'if-tag-badarg02' => array("{% if x|default_if_none:y %}yes{% endif %}", array('y' => 0), ''), 'if-tag-badarg03' => array("{% if x|default_if_none:y %}yes{% endif %}", array('y' => 1), 'yes'), 'if-tag-badarg04' => array("{% if x|default_if_none:y %}yes{% else %}no{% endif %}", array(), 'no'), 'ifchanged01' => array('{% for n in num %}{% ifchanged %}{{ n }}{% endifchanged %}{% endfor %}', array('num' => array(1, 2, 3)), '123'), 'ifchanged02' => array('{% for n in num %}{% ifchanged %}{{ n }}{% endifchanged %}{% endfor %}', array('num' => array(1, 1, 3)), '13'), 'ifchanged03' => array('{% for n in num %}{% ifchanged %}{{ n }}{% endifchanged %}{% endfor %}', array('num' => array(1, 1, 1)), '1'), 'ifchanged04' => array('{% for n in num %}{% ifchanged %}{{ n }}{% endifchanged %}{% for x in numx %}{% ifchanged %}{{ x }}{% endifchanged %}{% endfor %}{% endfor %}', array('num' => array(1, 2, 3), 'numx' => array(2, 2, 2)), '122232'), 'ifchanged05' => array('{% for n in num %}{% ifchanged %}{{ n }}{% endifchanged %}{% for x in numx %}{% ifchanged %}{{ x }}{% endifchanged %}{% endfor %}{% endfor %}', array('num' => array(1, 1, 1), 'numx' => array(1, 2, 3)), '1123123123'), 'ifchanged06' => array('{% for n in num %}{% ifchanged %}{{ n }}{% endifchanged %}{% for x in numx %}{% ifchanged %}{{ x }}{% endifchanged %}{% endfor %}{% endfor %}', array('num' => array(1, 1, 1), 'numx' => array(2, 2, 2)), '1222'), 'ifchanged07' => array('{% for n in num %}{% ifchanged %}{{ n }}{% endifchanged %}{% for x in numx %}{% ifchanged %}{{ x }}{% endifchanged %}{% for y in numy %}{% ifchanged %}{{ y }}{% endifchanged %}{% endfor %}{% endfor %}{% endfor %}', array('num' => array(1, 1, 1), 'numx' => array(2, 2, 2), 'numy' => array(3, 3, 3)), '1233323332333'), 'ifchanged-param01' => array('{% for n in num %}{% ifchanged n %}..{% endifchanged %}{{ n }}{% endfor %}', array('num' => array(1, 2, 3)), '..1..2..3'), 'ifchanged-param02' => array('{% for n in num %}{% for x in numx %}{% ifchanged n %}..{% endifchanged %}{{ x }}{% endfor %}{% endfor %}', array('num' => array(1, 2, 3), 'numx' => array(5, 6, 7)), '..567..567..567'), 'ifchanged-param03' => array('{% for n in num %}{{ n }}{% for x in numx %}{% ifchanged x n %}{{ x }}{% endifchanged %}{% endfor %}{% endfor %}', array('num' => array(1, 1, 2), 'numx' => array(5, 6, 6)), '156156256'), 'ifchanged-param04' => array('{% for d in days %}{% ifchanged %}{{ d.day }}{% endifchanged %}{% for h in d.hours %}{% ifchanged d h %}{{ h }}{% endifchanged %}{% endfor %}{% endfor %}', array('days' => array(array('day' => 1, 'hours' => array(1, 2, 3)), array('day' => 2, 'hours' => array(3)))), '112323'), 'ifchanged-param05' => array('{% for d in days %}{% ifchanged d.day %}{{ d.day }}{% endifchanged %}{% for h in d.hours %}{% ifchanged d.day h %}{{ h }}{% endifchanged %}{% endfor %}{% endfor %}', array('days' => array(array('day' => 1, 'hours' => array(1, 2, 3)), array('day' => 2, 'hours' => array(3)))), '112323'), 'ifchanged-else01' => array('{% for id in ids %}{{ id }}{% ifchanged id %}-first{% else %}-other{% endifchanged %},{% endfor %}', array('ids' => array(1, 1, 2, 2, 2, 3)), '1-first,1-other,2-first,2-other,2-other,3-first,'), 'ifchanged-else02' => array('{% for id in ids %}{{ id }}-{% ifchanged id %}{% cycle red,blue %}{% else %}grey{% endifchanged %},{% endfor %}', array('ids' => array(1, 1, 2, 2, 2, 3)), '1-red,1-grey,2-blue,2-grey,2-grey,3-red,'), 'ifchanged-else03' => array('{% for id in ids %}{{ id }}{% ifchanged id %}-{% cycle red,blue %}{% else %}{% endifchanged %},{% endfor %}', array('ids' => array(1, 1, 2, 2, 2, 3)), '1-red,1,2-blue,2,2,3-red,'), 'ifchanged-else04' => array('{% for id in ids %}{% ifchanged %}***{{ id }}*{% else %}...{% endifchanged %}{{ forloop.counter }}{% endfor %}', array('ids' => array(1, 1, 2, 2, 2, 3, 4)), '***1*1...2***2*3...4...5***3*6***4*7'), 'ifnotequal01' => array("{% ifnotequal a b %}yes{% endifnotequal %}", array("a" => 1, "b" => 2), "yes"), 'ifnotequal02' => array("{% ifnotequal a b %}yes{% endifnotequal %}", array("a" => 1, "b" => 1), ""), 'ifnotequal03' => array("{% ifnotequal a b %}yes{% else %}no{% endifnotequal %}", array("a" => 1, "b" => 2), "yes"), 'ifnotequal04' => array("{% ifnotequal a b %}yes{% else %}no{% endifnotequal %}", array("a" => 1, "b" => 1), "no"), 'include01' => array('{% include "basic-syntax01" %}', array(), "something cool"), 'include02' => array('{% include "basic-syntax02" %}', array('headline' => 'Included'), "Included"), 'include03' => array('{% include template_name %}', array('template_name' => 'basic-syntax02', 'headline' => 'Included'), "Included"), 'include04' => array('a{% include "nonexistent" %}b', array(), array("ab", "ab", 'TemplateDoesNotExist')), 'include 05' => array('template with a space', array(), 'template with a space'), 'include06' => array('{% include "include 05"%}', array(), 'template with a space'), 'include07' => array('{% include "basic-syntax02" with headline="Inline" %}', array('headline' => 'Included'), 'Inline'), 'include08' => array('{% include headline with headline="Dynamic" %}', array('headline' => 'basic-syntax02'), 'Dynamic'), 'include09' => array('{{ first }}--{% include "basic-syntax03" with first=second|lower|upper second=first|upper %}--{{ second }}', array('first' => 'Ul', 'second' => 'lU'), 'Ul--LU --- UL--lU'), 'include10' => array('{% include "basic-syntax03" only %}', array('first' => '1'), array(' --- ', 'INVALID --- INVALID')), 'include11' => array('{% include "basic-syntax03" only with second=2 %}', array('first' => '1'), array(' --- 2', 'INVALID --- 2')), 'include12' => array('{% include "basic-syntax03" with first=1 only %}', array('second' => '2'), array('1 --- ', '1 --- INVALID')), 'include13' => array('{% autoescape off %}{% include "basic-syntax03" %}{% endautoescape %}', array('first' => '&'), array('& --- ', '& --- INVALID')), 'include14' => array('{% autoescape off %}{% include "basic-syntax03" with first=var1 only %}{% endautoescape %}', array('var1' => '&'), array('& --- ', '& --- INVALID')), 'include-error01' => array('{% include "basic-syntax01" with %}', array(), 'TemplateSyntaxError'), 'include-error02' => array('{% include "basic-syntax01" with "no key" %}', array(), 'TemplateSyntaxError'), 'include-error03' => array('{% include "basic-syntax01" with dotted.arg="error" %}', array(), 'TemplateSyntaxError'), 'include-error04' => array('{% include "basic-syntax01" something_random %}', array(), 'TemplateSyntaxError'), 'include-error05' => array('{% include "basic-syntax01" foo="duplicate" foo="key" %}', array(), 'TemplateSyntaxError'), 'include-error06' => array('{% include "basic-syntax01" only only %}', array(), 'TemplateSyntaxError'), 'include-fail1' => array('{% load bad_tag %}{% badtag %}', array(), 'RuntimeError'), 'include-fail2' => array('{% load broken_tag %}', array(), 'TemplateSyntaxError'), 'include-error07' => array('{% include "include-fail1" %}', array(), array('', '', 'RuntimeError')), 'include-error08' => array('{% include "include-fail2" %}', array(), array('', '', 'TemplateSyntaxError')), 'include-error09' => array('{% include failed_include %}', array('failed_include' => 'include-fail1'), array('', '', 'RuntimeError')), 'include-error10' => array('{% include failed_include %}', array('failed_include' => 'include-fail2'), array('', '', 'TemplateSyntaxError')), 'namedendblocks01' => array("1{% block first %}_{% block second %}2{% endblock second %}_{% endblock first %}3", array(), '1_2_3'), 'namedendblocks02' => array("1{% block first %}_{% block second %}2{% endblock first %}_{% endblock second %}3", array(), 'TemplateSyntaxError'), 'namedendblocks03' => array("1{% block first %}_{% block second %}2{% endblock %}_{% endblock second %}3", array(), 'TemplateSyntaxError'), 'namedendblocks04' => array("1{% block first %}_{% block second %}2{% endblock second %}_{% endblock third %}3", array(), 'TemplateSyntaxError'), 'namedendblocks05' => array("1{% block first %}_{% block second %}2{% endblock first %}", array(), 'TemplateSyntaxError'), 'namedendblocks06' => array("1{% block first %}_{% block second %}2{% endblock %}_{% endblock first %}3", array(), '1_2_3'), 'namedendblocks07' => array("1{% block first %}_{% block second %}2{% endblock second %}_{% endblock %}3", array(), '1_2_3'), 'inheritance01' => array("1{% block first %}&{% endblock %}3{% block second %}_{% endblock %}", array(), '1&3_'), 'inheritance02' => array("{% extends 'inheritance01' %}{% block first %}2{% endblock %}{% block second %}4{% endblock %}", array(), '1234'), 'inheritance03' => array("{% extends 'inheritance02' %}", array(), '1234'), 'inheritance04' => array("{% extends 'inheritance01' %}", array(), '1&3_'), 'inheritance05' => array('{% extends "inheritance02" %}', array(), '1234'), 'inheritance06' => array("{% extends foo %}", array('foo' => 'inheritance02'), '1234'), 'inheritance07' => array("{% extends 'inheritance01' %}{% block second %}5{% endblock %}", array(), '1&35'), 'inheritance08' => array("{% extends 'inheritance02' %}{% block second %}5{% endblock %}", array(), '1235'), 'inheritance09' => array("{% extends 'inheritance04' %}", array(), '1&3_'), 'inheritance10' => array("{% extends 'inheritance04' %}      ", array(), '1&3_'), 'inheritance11' => array("{% extends 'inheritance04' %}{% block first %}2{% endblock %}{% block second %}4{% endblock %}", array(), '1234'), 'inheritance12' => array("{% extends 'inheritance07' %}{% block first %}2{% endblock %}", array(), '1235'), 'inheritance13' => array("{% extends 'inheritance02' %}{% block first %}a{% endblock %}{% block second %}b{% endblock %}", array(), '1a3b'), 'inheritance14' => array("{% extends 'inheritance01' %}{% block newblock %}NO DISPLAY{% endblock %}", array(), '1&3_'), 'inheritance15' => array("{% extends 'inheritance01' %}{% block first %}2{% block inner %}inner{% endblock %}{% endblock %}", array(), '12inner3_'), 'inheritance16' => array("{% extends 'inheritance15' %}{% block inner %}out{% endblock %}", array(), '12out3_'), 'inheritance17' => array("{% load testtags %}{% block first %}1234{% endblock %}", array(), '1234'), 'inheritance18' => array("{% load testtags %}{% echo this that theother %}5678", array(), 'this that theother5678'), 'inheritance19' => array("{% extends 'inheritance01' %}{% block first %}{% load testtags %}{% echo 400 %}5678{% endblock %}", array(), '140056783_'), 'inheritance20' => array("{% extends 'inheritance01' %}{% block first %}{{ block.super }}a{% endblock %}", array(), '1&a3_'), 'inheritance21' => array("{% extends 'inheritance02' %}{% block first %}{{ block.super }}a{% endblock %}", array(), '12a34'), 'inheritance22' => array("{% extends 'inheritance04' %}{% block first %}{{ block.super }}a{% endblock %}", array(), '1&a3_'), 'inheritance23' => array("{% extends 'inheritance20' %}{% block first %}{{ block.super }}b{% endblock %}", array(), '1&ab3_'), 'inheritance24' => array("{% extends context_template %}{% block first %}2{% endblock %}{% block second %}4{% endblock %}", array('context_template' => new Template("1{% block first %}_{% endblock %}3{% block second %}_{% endblock %}")), '1234'), 'inheritance25' => array("{% extends context_template.1 %}{% block first %}2{% endblock %}{% block second %}4{% endblock %}", array('context_template' => array(new Template("Wrong"), new Template("1{% block first %}_{% endblock %}3{% block second %}_{% endblock %}"))), '1234'), 'inheritance26' => array("no tags", array(), 'no tags'), 'inheritance27' => array("{% extends 'inheritance26' %}", array(), 'no tags'), 'inheritance 28' => array("{% block first %}!{% endblock %}", array(), '!'), 'inheritance29' => array("{% extends 'inheritance 28' %}", array(), '!'), 'inheritance30' => array("1{% if optional %}{% block opt %}2{% endblock %}{% endif %}3", array('optional' => True), '123'), 'inheritance31' => array("{% extends 'inheritance30' %}{% block opt %}two{% endblock %}", array('optional' => True), '1two3'), 'inheritance32' => array("{% extends 'inheritance30' %}{% block opt %}two{% endblock %}", array(), '13'), 'inheritance33' => array("1{% ifequal optional 1 %}{% block opt %}2{% endblock %}{% endifequal %}3", array('optional' => 1), '123'), 'inheritance34' => array("{% extends 'inheritance33' %}{% block opt %}two{% endblock %}", array('optional' => 1), '1two3'), 'inheritance35' => array("{% extends 'inheritance33' %}{% block opt %}two{% endblock %}", array('optional' => 2), '13'), 'inheritance36' => array("{% for n in numbers %}_{% block opt %}{{ n }}{% endblock %}{% endfor %}_", array('numbers' => '123'), '_1_2_3_'), 'inheritance37' => array("{% extends 'inheritance36' %}{% block opt %}X{% endblock %}", array('numbers' => '123'), '_X_X_X_'), 'inheritance38' => array("{% extends 'inheritance36' %}{% block opt %}X{% endblock %}", array(), '_'), 'inheritance39' => array("{% extends 'inheritance30' %}{% block opt %}new{{ block.super }}{% endblock %}", array('optional' => True), '1new23'), 'inheritance40' => array("{% extends 'inheritance33' %}{% block opt %}new{{ block.super }}{% endblock %}", array('optional' => 1), '1new23'), 'inheritance41' => array("{% extends 'inheritance36' %}{% block opt %}new{{ block.super }}{% endblock %}", array('numbers' => '123'), '_new1_new2_new3_'), 'load01' => array("{% load testtags subpackage.echo %}{% echo test %} {% echo2 \"test\" %}", array(), "test test"), 'load02' => array("{% load subpackage.echo %}{% echo2 \"test\" %}", array(), "test"), 'load03' => array("{% load echo from testtags %}{% echo this that theother %}", array(), 'this that theother'), 'load04' => array("{% load echo other_echo from testtags %}{% echo this that theother %} {% other_echo and another thing %}", array(), 'this that theother and another thing'), 'load05' => array("{% load echo upper from testtags %}{% echo this that theother %} {{ statement|upper }}", array('statement' => 'not shouting'), 'this that theother NOT SHOUTING'), 'load06' => array("{% load echo2 from subpackage.echo %}{% echo2 \"test\" %}", array(), "test"), 'load07' => array("{% load echo other_echo bad_tag from testtags %}", array(), 'TemplateSyntaxError'), 'load08' => array("{% load echo other_echo bad_tag from %}", array(), 'TemplateSyntaxError'), 'load09' => array("{% load from testtags %}", array(), 'TemplateSyntaxError'), 'load10' => array("{% load echo from bad_library %}", array(), 'TemplateSyntaxError'), 'load11' => array("{% load subpackage.echo_invalid %}", array(), 'TemplateSyntaxError'), 'load12' => array("{% load subpackage.missing %}", array(), 'TemplateSyntaxError'), 'spaceless01' => array("{% spaceless %} <b>    <i> text </i>    </b> {% endspaceless %}", array(), "<b><i> text </i></b>"), 'spaceless02' => array("{% spaceless %} <b> \n <i> text </i> \n </b> {% endspaceless %}", array(), "<b><i> text </i></b>"), 'spaceless03' => array("{% spaceless %}<b><i>text</i></b>{% endspaceless %}", array(), "<b><i>text</i></b>"), 'spaceless04' => array("{% spaceless %}<b>   <i>{{ text }}</i>  </b>{% endspaceless %}", array('text' => 'This & that'), "<b><i>This &amp; that</i></b>"), 'spaceless05' => array("{% autoescape off %}{% spaceless %}<b>   <i>{{ text }}</i>  </b>{% endspaceless %}{% endautoescape %}", array('text' => 'This & that'), "<b><i>This & that</i></b>"), 'spaceless06' => array("{% spaceless %}<b>   <i>{{ text|safe }}</i>  </b>{% endspaceless %}", array('text' => 'This & that'), "<b><i>This & that</i></b>"), 'i18n01' => array("{% load i18n %}{% trans 'xxxyyyxxx' %}", array(), "xxxyyyxxx"), 'i18n02' => array('{% load i18n %}{% trans "xxxyyyxxx" %}', array(), "xxxyyyxxx"), 'i18n03' => array('{% load i18n %}{% blocktrans %}{{ anton }}{% endblocktrans %}', array('anton' => 'Å'), "Å"), 'i18n04' => array('{% load i18n %}{% blocktrans with berta=anton|lower %}{{ berta }}{% endblocktrans %}', array('anton' => 'å'), 'å'), 'legacyi18n04' => array('{% load i18n %}{% blocktrans with anton|lower as berta %}{{ berta }}{% endblocktrans %}', array('anton' => 'å'), 'å'), 'i18n05' => array('{% load i18n %}{% blocktrans %}xxx{{ anton }}xxx{% endblocktrans %}', array('anton' => 'yyy'), "xxxyyyxxx"), 'i18n06' => array('{% load i18n %}{% trans "Page not found" %}', array('LANGUAGE_CODE' => 'de'), "Seite nicht gefunden"), 'i18n07' => array('{% load i18n %}{% blocktrans count counter=number %}singular{% plural %}{{ counter }} plural{% endblocktrans %}', array('number' => 1), "singular"), 'legacyi18n07' => array('{% load i18n %}{% blocktrans count number as counter %}singular{% plural %}{{ counter }} plural{% endblocktrans %}', array('number' => 1), "singular"), 'i18n08' => array('{% load i18n %}{% blocktrans count number as counter %}singular{% plural %}{{ counter }} plural{% endblocktrans %}', array('number' => 2), "2 plural"), 'legacyi18n08' => array('{% load i18n %}{% blocktrans count counter=number %}singular{% plural %}{{ counter }} plural{% endblocktrans %}', array('number' => 2), "2 plural"), 'i18n09' => array('{% load i18n %}{% trans "Page not found" noop %}', array('LANGUAGE_CODE' => 'de'), "Page not found"), 'i18n10' => array('{{ bool|yesno:_("yes,no,maybe") }}', array('bool' => True, 'LANGUAGE_CODE' => 'de'), 'Ja'), 'i18n11' => array('{{ bool|yesno:"ja,nein" }}', array('bool' => True), 'ja'), 'i18n12' => array('{% load i18n %}{% get_available_languages as langs %}{% for lang in langs %}{% ifequal lang.0 "de" %}{{ lang.0 }}{% endifequal %}{% endfor %}', array(), 'de'), 'i18n13' => array('{{ _("Password") }}', array('LANGUAGE_CODE' => 'de'), 'Passwort'), 'i18n14' => array('{% cycle "foo" _("Password") _(\'Password\') as c %} {% cycle c %} {% cycle c %}', array('LANGUAGE_CODE' => 'de'), 'foo Passwort Passwort'), 'i18n15' => array('{{ absent|default:_("Password") }}', array('LANGUAGE_CODE' => 'de', 'absent' => ""), 'Passwort'), 'i18n16' => array('{{ _("<") }}', array('LANGUAGE_CODE' => 'de'), '<'), 'i18n17' => array('{% load i18n %}{% blocktrans with berta=anton|escape %}{{ berta }}{% endblocktrans %}', array('anton' => 'α & β'), 'α &amp; β'), 'i18n18' => array('{% load i18n %}{% blocktrans with berta=anton|force_escape %}{{ berta }}{% endblocktrans %}', array('anton' => 'α & β'), 'α &amp; β'), 'i18n19' => array('{% load i18n %}{% blocktrans %}{{ andrew }}{% endblocktrans %}', array('andrew' => 'a & b'), 'a &amp; b'), 'i18n20' => array('{% load i18n %}{% trans andrew %}', array('andrew' => 'a & b'), 'a &amp; b'), 'i18n21' => array('{% load i18n %}{% blocktrans %}{{ andrew }}{% endblocktrans %}', array('andrew' => mark_safe('a & b')), 'a & b'), 'i18n22' => array('{% load i18n %}{% trans andrew %}', array('andrew' => mark_safe('a & b')), 'a & b'), 'legacyi18n17' => array('{% load i18n %}{% blocktrans with anton|escape as berta %}{{ berta }}{% endblocktrans %}', array('anton' => 'α & β'), 'α &amp; β'), 'legacyi18n18' => array('{% load i18n %}{% blocktrans with anton|force_escape as berta %}{{ berta }}{% endblocktrans %}', array('anton' => 'α & β'), 'α &amp; β'), 'i18n23' => array('{% load i18n %}{% trans "Page not found"|capfirst|slice:"6:" %}', array('LANGUAGE_CODE' => 'de'), 'nicht gefunden'), 'i18n24' => array("{% load i18n %}{% trans 'Page not found'|upper %}", array('LANGUAGE_CODE' => 'de'), 'SEITE NICHT GEFUNDEN'), 'i18n25' => array('{% load i18n %}{% trans somevar|upper %}', array('somevar' => 'Page not found', 'LANGUAGE_CODE' => 'de'), 'SEITE NICHT GEFUNDEN'), 'i18n26' => array('{% load i18n %}{% blocktrans with extra_field=myextra_field count counter=number %}singular {{ extra_field }}{% plural %}plural{% endblocktrans %}', array('number' => 1, 'myextra_field' => 'test'), "singular test"), 'legacyi18n26' => array('{% load i18n %}{% blocktrans with myextra_field as extra_field count number as counter %}singular {{ extra_field }}{% plural %}plural{% endblocktrans %}', array('number' => 1, 'myextra_field' => 'test'), "singular test"), 'i18n27' => array('{% load i18n %}{% blocktrans count counter=number %}{{ counter }} result{% plural %}{{ counter }} results{% endblocktrans %}', array('number' => 1, 'LANGUAGE_CODE' => 'ru'), '1 результат'), 'legacyi18n27' => array('{% load i18n %}{% blocktrans count number as counter %}{{ counter }} result{% plural %}{{ counter }} results{% endblocktrans %}', array('number' => 1, 'LANGUAGE_CODE' => 'ru'), '1 результат'), 'i18n28' => array('{% load i18n %}{% blocktrans with a=anton b=berta %}{{ a }} + {{ b }}{% endblocktrans %}', array('anton' => 'α', 'berta' => 'β'), 'α + β'), 'legacyi18n28' => array('{% load i18n %}{% blocktrans with anton as a and berta as b %}{{ a }} + {{ b }}{% endblocktrans %}', array('anton' => 'α', 'berta' => 'β'), 'α + β'), 'i18n34' => array('{% load i18n %}{% blocktrans %}{{ missing }}{% endblocktrans %}', array(), ''), 'i18n35' => array('{% load i18n %}{% trans "Page not found" as page_not_found %}{{ page_not_found }}', array('LANGUAGE_CODE' => 'de'), "Seite nicht gefunden"), 'i18n36' => array('{% load i18n %}{% trans "Page not found" noop as page_not_found %}{{ page_not_found }}', array('LANGUAGE_CODE' => 'de'), "Page not found"), 'i18n36' => array('{% load i18n %}{% trans "Page not found" as page_not_found noop %}{{ page_not_found }}', array('LANGUAGE_CODE' => 'de'), "Page not found"), 'i18n37' => array('{% load i18n %}{% trans "Page not found" as page_not_found %}{% blocktrans %}Error: {{ page_not_found }}{% endblocktrans %}', array('LANGUAGE_CODE' => 'de'), "Error: Seite nicht gefunden"), 'invalidstr01' => array('{{ var|default:"Foo" }}', array(), array('Foo', 'INVALID')), 'invalidstr02' => array('{{ var|default_if_none:"Foo" }}', array(), array('', 'INVALID')), 'invalidstr03' => array('{% for v in var %}({{ v }}){% endfor %}', array(), ''), 'invalidstr04' => array('{% if var %}Yes{% else %}No{% endif %}', array(), 'No'), 'invalidstr04_2' => array('{% if var|default:"Foo" %}Yes{% else %}No{% endif %}', array(), 'Yes'), 'invalidstr05' => array('{{ var }}', array(), array('', array('INVALID %s', 'var'))), 'invalidstr06' => array('{{ var.prop }}', array('var' => array()), array('', array('INVALID %s', 'var.prop'))), 'multiline01' => array('
                         Hello,
                         boys.
                         How
                         are
                         you
                         gentlemen.
                         ', array(), '
                         Hello,
                         boys.
                         How
                         are
                         you
                         gentlemen.
                         '), 'regroup01' => array('{% regroup data by bar as grouped %}' . '{% for group in grouped %}' . '{{ group.grouper }}:' . '{% for item in group.list %}' . '{{ item.foo }}' . '{% endfor %},' . '{% endfor %}', array('data' => array(array('foo' => 'c', 'bar' => 1), array('foo' => 'd', 'bar' => 1), array('foo' => 'a', 'bar' => 2), array('foo' => 'b', 'bar' => 2), array('foo' => 'x', 'bar' => 3))), '1:cd,2:ab,3:x,'), 'regroup02' => array('{% regroup data by bar as grouped %}' . '{% for group in grouped %}' . '{{ group.grouper }}:' . '{% for item in group.list %}' . '{{ item.foo }}' . '{% endfor %},' . '{% endfor %}', array(), ''), 'regroup03' => array('{% regroup data by at|date:"m" as grouped %}' . '{% for group in grouped %}' . '{{ group.grouper }}:' . '{% for item in group.list %}' . '{{ item.at|date:"d" }}' . '{% endfor %},' . '{% endfor %}', array('data' => array(array('at' => mktime(0, 0, 0, 2, 14, 2012)), array('at' => mktime(0, 0, 0, 2, 28, 2012)), array('at' => mktime(0, 0, 0, 7, 4, 2012)))), '02:1428,07:04,'), 'regroup04' => array('{% regroup data by bar|join:"" as grouped %}' . '{% for group in grouped %}' . '{{ group.grouper }}:' . '{% for item in group.list %}' . '{{ item.foo|first }}' . '{% endfor %},' . '{% endfor %}', array('data' => array(array('foo' => 'x', 'bar' => array('ab', 'c')), array('foo' => 'y', 'bar' => array('a', 'bc')), array('foo' => 'z', 'bar' => array('a', 'd')))), 'abc:xy,ad:z,'), 'templatetag01' => array('{% templatetag openblock %}', array(), '{%'), 'templatetag02' => array('{% templatetag closeblock %}', array(), '%}'), 'templatetag03' => array('{% templatetag openvariable %}', array(), '{{'), 'templatetag04' => array('{% templatetag closevariable %}', array(), '}}'), 'templatetag05' => array('{% templatetag %}', array(), 'TemplateSyntaxError'), 'templatetag06' => array('{% templatetag foo %}', array(), 'TemplateSyntaxError'), 'templatetag07' => array('{% templatetag openbrace %}', array(), '{'), 'templatetag08' => array('{% templatetag closebrace %}', array(), '}'), 'templatetag09' => array('{% templatetag openbrace %}{% templatetag openbrace %}', array(), '{{'), 'templatetag10' => array('{% templatetag closebrace %}{% templatetag closebrace %}', array(), '}}'), 'templatetag11' => array('{% templatetag opencomment %}', array(), '{#'), 'templatetag12' => array('{% templatetag closecomment %}', array(), '#}'), 'simpletag-renamed01' => array('{% load custom %}{% minusone 7 %}', array(), '6'), 'simpletag-renamed02' => array('{% load custom %}{% minustwo 7 %}', array(), '5'), 'simpletag-renamed03' => array('{% load custom %}{% minustwo_overridden_name 7 %}', array(), 'TemplateSyntaxError'), 'widthratio01' => array('{% widthratio a b 0 %}', array('a' => 50, 'b' => 100), '0'), 'widthratio02' => array('{% widthratio a b 100 %}', array('a' => 0, 'b' => 0), '0'), 'widthratio03' => array('{% widthratio a b 100 %}', array('a' => 0, 'b' => 100), '0'), 'widthratio04' => array('{% widthratio a b 100 %}', array('a' => 50, 'b' => 100), '50'), 'widthratio05' => array('{% widthratio a b 100 %}', array('a' => 100, 'b' => 100), '100'), 'widthratio06' => array('{% widthratio a b 100 %}', array('a' => 50, 'b' => 80), '63'), 'widthratio07' => array('{% widthratio a b 100 %}', array('a' => 50, 'b' => 70), '71'), 'widthratio08' => array('{% widthratio %}', array(), 'TemplateSyntaxError'), 'widthratio09' => array('{% widthratio a b %}', array('a' => 50, 'b' => 100), 'TemplateSyntaxError'), 'widthratio10' => array('{% widthratio a b 100.0 %}', array('a' => 50, 'b' => 100), '50'), 'widthratio11' => array('{% widthratio a b c %}', array('a' => 50, 'b' => 100, 'c' => 100), '50'), 'widthratio12a' => array('{% widthratio a b c %}', array('a' => 'a', 'b' => 100, 'c' => 100), ''), 'widthratio12b' => array('{% widthratio a b c %}', array('a' => null, 'b' => 100, 'c' => 100), ''), 'widthratio13a' => array('{% widthratio a b c %}', array('a' => 0, 'b' => 'b', 'c' => 100), ''), 'widthratio13b' => array('{% widthratio a b c %}', array('a' => 0, 'b' => null, 'c' => 100), ''), 'widthratio14a' => array('{% widthratio a b c %}', array('a' => 0, 'b' => 100, 'c' => 'c'), 'TemplateSyntaxError'), 'widthratio14b' => array('{% widthratio a b c %}', array('a' => 0, 'b' => 100, 'c' => null), 'TemplateSyntaxError'), 'with01' => array('{% with key=dict.key %}{{ key }}{% endwith %}', array('dict' => array('key' => 50)), '50'), 'legacywith01' => array('{% with dict.key as key %}{{ key }}{% endwith %}', array('dict' => array('key' => 50)), '50'), 'with02' => array('{{ key }}{% with key=dict.key %}{{ key }}-{{ dict.key }}-{{ key }}{% endwith %}{{ key }}', array('dict' => array('key' => 50)), array('50-50-50', 'INVALID50-50-50INVALID')), 'legacywith02' => array('{{ key }}{% with dict.key as key %}{{ key }}-{{ dict.key }}-{{ key }}{% endwith %}{{ key }}', array('dict' => array('key' => 50)), array('50-50-50', 'INVALID50-50-50INVALID')), 'with03' => array('{% with a=alpha b=beta %}{{ a }}{{ b }}{% endwith %}', array('alpha' => 'A', 'beta' => 'B'), 'AB'), 'with-error01' => array('{% with dict.key xx key %}{{ key }}{% endwith %}', array('dict' => array('key' => 50)), 'TemplateSyntaxError'), 'with-error02' => array('{% with dict.key as %}{{ key }}{% endwith %}', array('dict' => array('key' => 50)), 'TemplateSyntaxError'), 'now01' => array('{% now "j n Y" %}', array(), date('j') . ' ' . date('n') . ' ' . date('Y')), 'now02' => array('{% now "DATE_FORMAT" %}', array(), dja_date_format(time())), 'now03' => array("{% now 'j n Y' %}", array(), date('j') . ' ' . date('n') . ' ' . date('Y')), 'now04' => array("{% now 'DATE_FORMAT' %}", array(), dja_date_format(time())), 'now05' => array('{% now \'j "n" Y\'%}', array(), date('j') . ' "' . date('n') . '" ' . date('Y')), 'now06' => array('{% now "j \'n\' Y"%}', array(), date('j') . ' \'' . date('n') . '\' ' . date('Y')), 'legacyurl02' => array('{% url regressiontests.templates.views.client_action id=client.id,action="update" %}', array('client' => array('id' => 1)), '/url_tag/client/1/update/'), 'legacyurl02a' => array('{% url regressiontests.templates.views.client_action client.id,"update" %}', array('client' => array('id' => 1)), '/url_tag/client/1/update/'), 'legacyurl02b' => array("{% url regressiontests.templates.views.client_action id=client.id,action='update' %}", array('client' => array('id' => 1)), '/url_tag/client/1/update/'), 'legacyurl02c' => array("{% url regressiontests.templates.views.client_action client.id,'update' %}", array('client' => array('id' => 1)), '/url_tag/client/1/update/'), 'legacyurl10' => array('{% url regressiontests.templates.views.client_action id=client.id,action="two words" %}', array('client' => array('id' => 1)), '/url_tag/client/1/two%20words/'), 'legacyurl13' => array('{% url regressiontests.templates.views.client_action id=client.id, action=arg|join:"-" %}', array('client' => array('id' => 1), 'arg' => array('a', 'b')), '/url_tag/client/1/a-b/'), 'legacyurl14' => array('{% url regressiontests.templates.views.client_action client.id, arg|join:"-" %}', array('client' => array('id' => 1), 'arg' => array('a', 'b')), '/url_tag/client/1/a-b/'), 'legacyurl16' => array('{% url regressiontests.templates.views.client_action action="update",id="1" %}', array(), '/url_tag/client/1/update/'), 'legacyurl16a' => array("{% url regressiontests.templates.views.client_action action='update',id='1' %}", array(), '/url_tag/client/1/update/'), 'legacyurl17' => array('{% url regressiontests.templates.views.client_action client_id=client.my_id,action=action %}', array('client' => array('my_id' => 1), 'action' => 'update'), '/url_tag/client/1/update/'), 'old-url01' => array('{% url regressiontests.templates.views.client client.id %}', array('client' => array('id' => 1)), '/url_tag/client/1/'), 'old-url02' => array('{% url regressiontests.templates.views.client_action id=client.id action="update" %}', array('client' => array('id' => 1)), '/url_tag/client/1/update/'), 'old-url02a' => array('{% url regressiontests.templates.views.client_action client.id "update" %}', array('client' => array('id' => 1)), '/url_tag/client/1/update/'), 'old-url02b' => array("{% url regressiontests.templates.views.client_action id=client.id action='update' %}", array('client' => array('id' => 1)), '/url_tag/client/1/update/'), 'old-url02c' => array("{% url regressiontests.templates.views.client_action client.id 'update' %}", array('client' => array('id' => 1)), '/url_tag/client/1/update/'), 'old-url03' => array('{% url regressiontests.templates.views.index %}', array(), '/url_tag/'), 'old-url04' => array('{% url named.client client.id %}', array('client' => array('id' => 1)), '/url_tag/named-client/1/'), 'old-url05' => array('{% url метка_оператора v %}', array('v' => 'Ω'), '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'), 'old-url06' => array('{% url метка_оператора_2 tag=v %}', array('v' => 'Ω'), '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'), 'old-url08' => array('{% url метка_оператора v %}', array('v' => 'Ω'), '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'), 'old-url09' => array('{% url метка_оператора_2 tag=v %}', array('v' => 'Ω'), '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'), 'old-url10' => array('{% url regressiontests.templates.views.client_action id=client.id action="two words" %}', array('client' => array('id' => 1)), '/url_tag/client/1/two%20words/'), 'old-url11' => array('{% url regressiontests.templates.views.client_action id=client.id action="==" %}', array('client' => array('id' => 1)), '/url_tag/client/1/==/'), 'old-url12' => array('{% url regressiontests.templates.views.client_action id=client.id action="," %}', array('client' => array('id' => 1)), '/url_tag/client/1/,/'), 'old-url13' => array('{% url regressiontests.templates.views.client_action id=client.id action=arg|join:"-" %}', array('client' => array('id' => 1), 'arg' => array('a', 'b')), '/url_tag/client/1/a-b/'), 'old-url14' => array('{% url regressiontests.templates.views.client_action client.id arg|join:"-" %}', array('client' => array('id' => 1), 'arg' => array('a', 'b')), '/url_tag/client/1/a-b/'), 'old-url15' => array('{% url regressiontests.templates.views.client_action 12 "test" %}', array(), '/url_tag/client/12/test/'), 'old-url16' => array('{% url regressiontests.templates.views.client "1,2" %}', array(), '/url_tag/client/1,2/'), 'old-url-fail01' => array('{% url %}', array(), 'TemplateSyntaxError'), 'old-url-fail02' => array('{% url no_such_view %}', array(), array('UrlNoReverseMatch', 'UrlNoReverseMatch')), 'old-url-fail03' => array('{% url regressiontests.templates.views.client %}', array(), array('UrlNoReverseMatch', 'UrlNoReverseMatch')), 'old-url-fail04' => array('{% url view id, %}', array(), 'TemplateSyntaxError'), 'old-url-fail05' => array('{% url view id= %}', array(), 'TemplateSyntaxError'), 'old-url-fail06' => array('{% url view a.id=id %}', array(), 'TemplateSyntaxError'), 'old-url-fail07' => array('{% url view a.id!id %}', array(), 'TemplateSyntaxError'), 'old-url-fail08' => array('{% url view id="unterminatedstring %}', array(), 'TemplateSyntaxError'), 'old-url-fail09' => array('{% url view id=", %}', array(), 'TemplateSyntaxError'), 'old-url-asvar01' => array('{% url regressiontests.templates.views.index as url %}', array(), ''), 'old-url-asvar02' => array('{% url regressiontests.templates.views.index as url %}{{ url }}', array(), '/url_tag/'), 'old-url-asvar03' => array('{% url no_such_view as url %}{{ url }}', array(), ''), 'url01' => array('{% load url from future %}{% url "regressiontests.templates.views.client" client.id %}', array('client' => array('id' => 1)), '/url_tag/client/1/'), 'url02' => array('{% load url from future %}{% url "regressiontests.templates.views.client_action" id=client.id action="update" %}', array('client' => array('id' => 1)), '/url_tag/client/1/update/'), 'url02a' => array('{% load url from future %}{% url "regressiontests.templates.views.client_action" client.id "update" %}', array('client' => array('id' => 1)), '/url_tag/client/1/update/'), 'url02b' => array("{% load url from future %}{% url 'regressiontests.templates.views.client_action' id=client.id action='update' %}", array('client' => array('id' => 1)), '/url_tag/client/1/update/'), 'url02c' => array("{% load url from future %}{% url 'regressiontests.templates.views.client_action' client.id 'update' %}", array('client' => array('id' => 1)), '/url_tag/client/1/update/'), 'url03' => array('{% load url from future %}{% url "regressiontests.templates.views.index" %}', array(), '/url_tag/'), 'url04' => array('{% load url from future %}{% url "named.client" client.id %}', array('client' => array('id' => 1)), '/url_tag/named-client/1/'), 'url05' => array('{% load url from future %}{% url "метка_оператора" v %}', array('v' => 'Ω'), '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'), 'url06' => array('{% load url from future %}{% url "метка_оператора_2" tag=v %}', array('v' => 'Ω'), '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'), 'url08' => array('{% load url from future %}{% url "метка_оператора" v %}', array('v' => 'Ω'), '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'), 'url09' => array('{% load url from future %}{% url "метка_оператора_2" tag=v %}', array('v' => 'Ω'), '/url_tag/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/'), 'url10' => array('{% load url from future %}{% url "regressiontests.templates.views.client_action" id=client.id action="two words" %}', array('client' => array('id' => 1)), '/url_tag/client/1/two%20words/'), 'url11' => array('{% load url from future %}{% url "regressiontests.templates.views.client_action" id=client.id action="==" %}', array('client' => array('id' => 1)), '/url_tag/client/1/==/'), 'url12' => array('{% load url from future %}{% url "regressiontests.templates.views.client_action" id=client.id action="," %}', array('client' => array('id' => 1)), '/url_tag/client/1/,/'), 'url13' => array('{% load url from future %}{% url "regressiontests.templates.views.client_action" id=client.id action=arg|join:"-" %}', array('client' => array('id' => 1), 'arg' => array('a', 'b')), '/url_tag/client/1/a-b/'), 'url14' => array('{% load url from future %}{% url "regressiontests.templates.views.client_action" client.id arg|join:"-" %}', array('client' => array('id' => 1), 'arg' => array('a', 'b')), '/url_tag/client/1/a-b/'), 'url15' => array('{% load url from future %}{% url "regressiontests.templates.views.client_action" 12 "test" %}', array(), '/url_tag/client/12/test/'), 'url18' => array('{% load url from future %}{% url "regressiontests.templates.views.client" "1,2" %}', array(), '/url_tag/client/1,2/'), 'url19' => array('{% load url from future %}{% url named_url client.id %}', array('named_url' => 'regressiontests.templates.views.client', 'client' => array('id' => 1)), '/url_tag/client/1/'), 'url20' => array('{% load url from future %}{% url url_name_in_var client.id %}', array('url_name_in_var' => 'named.client', 'client' => array('id' => 1)), '/url_tag/named-client/1/'), 'url-fail01' => array('{% load url from future %}{% url %}', array(), 'TemplateSyntaxError'), 'url-fail02' => array('{% load url from future %}{% url "no_such_view" %}', array(), array('UrlNoReverseMatch', 'UrlNoReverseMatch')), 'url-fail03' => array('{% load url from future %}{% url "regressiontests.templates.views.client" %}', array(), array('UrlNoReverseMatch', 'UrlNoReverseMatch')), 'url-fail04' => array('{% load url from future %}{% url "view" id, %}', array(), 'TemplateSyntaxError'), 'url-fail05' => array('{% load url from future %}{% url "view" id= %}', array(), 'TemplateSyntaxError'), 'url-fail06' => array('{% load url from future %}{% url "view" a.id=id %}', array(), 'TemplateSyntaxError'), 'url-fail07' => array('{% load url from future %}{% url "view" a.id!id %}', array(), 'TemplateSyntaxError'), 'url-fail08' => array('{% load url from future %}{% url "view" id="unterminatedstring %}', array(), 'TemplateSyntaxError'), 'url-fail09' => array('{% load url from future %}{% url "view" id=", %}', array(), 'TemplateSyntaxError'), 'url-fail11' => array('{% load url from future %}{% url named_url %}', array(), array('UrlNoReverseMatch', 'UrlNoReverseMatch')), 'url-fail12' => array('{% load url from future %}{% url named_url %}', array('named_url' => 'no_such_view'), array('UrlNoReverseMatch', 'UrlNoReverseMatch')), 'url-fail13' => array('{% load url from future %}{% url named_url %}', array('named_url' => 'regressiontests.templates.views.client'), array('UrlNoReverseMatch', 'UrlNoReverseMatch')), 'url-fail14' => array('{% load url from future %}{% url named_url id, %}', array('named_url' => 'view'), 'TemplateSyntaxError'), 'url-fail15' => array('{% load url from future %}{% url named_url id= %}', array('named_url' => 'view'), 'TemplateSyntaxError'), 'url-fail16' => array('{% load url from future %}{% url named_url a.id=id %}', array('named_url' => 'view'), 'TemplateSyntaxError'), 'url-fail17' => array('{% load url from future %}{% url named_url a.id!id %}', array('named_url' => 'view'), 'TemplateSyntaxError'), 'url-fail18' => array('{% load url from future %}{% url named_url id="unterminatedstring %}', array('named_url' => 'view'), 'TemplateSyntaxError'), 'url-fail19' => array('{% load url from future %}{% url named_url id=", %}', array('named_url' => 'view'), 'TemplateSyntaxError'), 'url-asvar01' => array('{% load url from future %}{% url "regressiontests.templates.views.index" as url %}', array(), ''), 'url-asvar02' => array('{% load url from future %}{% url "regressiontests.templates.views.index" as url %}{{ url }}', array(), '/url_tag/'), 'url-asvar03' => array('{% load url from future %}{% url "no_such_view" as url %}{{ url }}', array(), ''), 'cache03' => array('{% load cache %}{% cache 2 test %}cache03{% endcache %}', array(), 'cache03'), 'cache04' => array('{% load cache %}{% cache 2 test %}cache04{% endcache %}', array(), 'cache03'), 'cache05' => array('{% load cache %}{% cache 2 test foo %}cache05{% endcache %}', array('foo' => 1), 'cache05'), 'cache06' => array('{% load cache %}{% cache 2 test foo %}cache06{% endcache %}', array('foo' => 2), 'cache06'), 'cache07' => array('{% load cache %}{% cache 2 test foo %}cache07{% endcache %}', array('foo' => 1), 'cache05'), 'cache08' => array('{% load cache %}{% cache time test foo %}cache08{% endcache %}', array('foo' => 2, 'time' => 2), 'cache06'), 'cache11' => array('{% load cache %}{% cache %}{% endcache %}', array(), 'TemplateSyntaxError'), 'cache12' => array('{% load cache %}{% cache 1 %}{% endcache %}', array(), 'TemplateSyntaxError'), 'cache13' => array('{% load cache %}{% cache foo bar %}{% endcache %}', array(), 'TemplateSyntaxError'), 'cache14' => array('{% load cache %}{% cache foo bar %}{% endcache %}', array('foo' => 'fail'), 'TemplateSyntaxError'), 'cache15' => array('{% load cache %}{% cache foo bar %}{% endcache %}', array('foo' => array()), 'TemplateSyntaxError'), 'cache16' => array('{% load cache %}{% cache 1 foo bar %}{% endcache %}', array('foo' => 'foo', 'bar' => 'with spaces'), ''), 'cache17' => array('{% load cache %}{% cache 10 long_cache_key poem %}Some Content{% endcache %}', array('poem' => 'Oh freddled gruntbuggly/Thy micturations are to me/As plurdled gabbleblotchits/On a lurgid bee/That mordiously hath bitled out/Its earted jurtles/Into a rancid festering/Or else I shall rend thee in the gobberwarts with my blurglecruncheon/See if I dont.'), 'Some Content'), 'autoescape-tag01' => array("{% autoescape off %}hello{% endautoescape %}", array(), "hello"), 'autoescape-tag02' => array("{% autoescape off %}{{ first }}{% endautoescape %}", array("first" => "<b>hello</b>"), "<b>hello</b>"), 'autoescape-tag03' => array("{% autoescape on %}{{ first }}{% endautoescape %}", array("first" => "<b>hello</b>"), "&lt;b&gt;hello&lt;/b&gt;"), 'autoescape-tag04' => array("{% autoescape off %}{{ first }} {% autoescape  on%}{{ first }}{% endautoescape %}{% endautoescape %}", array("first" => "<a>"), "<a> &lt;a&gt;"), 'autoescape-tag05' => array("{% autoescape on %}{{ first }}{% endautoescape %}", array("first" => "<b>first</b>"), "&lt;b&gt;first&lt;/b&gt;"), 'autoescape-tag06' => array("{{ first }}", array("first" => mark_safe("<b>first</b>")), "<b>first</b>"), 'autoescape-tag07' => array("{% autoescape on %}{{ first }}{% endautoescape %}", array("first" => mark_safe("<b>Apple</b>")), "<b>Apple</b>"), 'autoescape-tag08' => array('{% autoescape on %}{{ var|default_if_none:" endquote\\" hah" }}{% endautoescape %}', array("var" => null), ' endquote" hah'), 'autoescape-tag09' => array('{{ unsafe }}', array('unsafe' => new UnsafeClass()), 'you &amp; me'), 'autoescape-tag10' => array('{{ safe }}', array('safe' => new SafeClass()), 'you &gt; me'), 'autoescape-filtertag01' => array("{{ first }}{% filter safe %}{{ first }} x<y{% endfilter %}", array("first" => "<a>"), 'TemplateSyntaxError'), 'autoescape-ifequal01' => array('{% ifequal var "this & that" %}yes{% endifequal %}', array("var" => "this & that"), "yes"), 'autoescape-filters01' => array('{{ var|cut:"&" }}', array("var" => "this & that"), "this  that"), 'autoescape-filters02' => array('{{ var|join:" & " }}', array("var" => array("Tom", "Dick", "Harry")), "Tom & Dick & Harry"), 'autoescape-literals01' => array('{{ "this & that" }}', array(), "this & that"), 'autoescape-stringiterations01' => array('{% for l in var %}{{ l }},{% endfor %}', array('var' => 'K&R'), "K,&amp;,R,"), 'autoescape-lookup01' => array('{{ var.key }}', array("var" => array("key" => "this & that")), "this &amp; that"), 'verbatim-tag01' => array('{% verbatim %}{{bare   }}{% endverbatim %}', array(), '{{bare   }}'), 'verbatim-tag02' => array('{% verbatim %}{% endif %}{% endverbatim %}', array(), '{% endif %}'), 'verbatim-tag03' => array("{% verbatim %}It's the {% verbatim %} tag{% endverbatim %}", array(), "It's the {% verbatim %} tag"), 'verbatim-tag04' => array('{% verbatim %}{% verbatim %}{% endverbatim %}{% endverbatim %}', array(), 'TemplateSyntaxError'), 'verbatim-tag05' => array('{% verbatim %}{% endverbatim %}{% verbatim %}{% endverbatim %}', array(), ''), 'verbatim-tag06' => array("{% verbatim special %}Don't {% endverbatim %} just yet{% endverbatim special %}", array(), "Don't {% endverbatim %} just yet"));
     return $tests;
 }
Пример #7
0
                    $sublist_item = $next_item;
                    // We've processed the next item now too.
                    $i += 1;
                }
            }
            if ($sublist_item) {
                $sublist = $_helper($sublist_item, $tabs + 1);
                $sublist = sprintf("\n%s<ul>\n%s\n%s</ul>\n%s", $indent, $sublist, $indent, $indent);
            }
            $output[] = $indent . '<li>' . $escaper($title) . $sublist . '</li>';
            $i += 1;
        }
        return join("\n", $output);
    };
    list($value, $converted) = $convert_old_style_list($value);
    return mark_safe($_helper($value, 1, $escaper));
}, array('is_safe' => True, 'needs_autoescape' => True));
/*
 * INTEGERS
 */
$lib->filter('add', function ($value, $arg) {
    if ($arg instanceof SafeData) {
        $arg = $arg->get();
    }
    if (is_string($value) && is_string($arg)) {
        return $value . $arg;
    }
    if (is_numeric($value) && is_numeric($arg)) {
        return $value + $arg;
    }
    if (is_array($value) && is_array($arg)) {