-
Notifications
You must be signed in to change notification settings - Fork 4
/
test.tpl
55 lines (47 loc) · 1.77 KB
/
test.tpl
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{# Testing inheritance #}
Before extends
{% extends middle_test.tpl %}
{% block mainContent %}
{# Testing loop and condition tags #}
{% for item in items %}
{% if item.active && length(item.text) == 3 %}
<div class="active">{{ item.text }}</div>
{% else %}
<div class="inactive">{{ item.text }}</div>
{% endif %}
{% endfor %}
{# Testing expression parser #}
{{ "f" * 8 + "u" * 8 + "~" }} should be ffffffffuuuuuuuu~
{{upper("f"*8+"u"*8+"~")}} should be FFFFFFFFUUUUUUUU~
{{ sin( 0 )}} should be 0
{{ cos( 0 ) }} should be 1
{{ length( [] ) }} should be 0
{{ length( [ 2, 4, { "s": 55 } ] ) }} should be 3
{{ length( { "key1": "value1", "key2": "value2" } ) }} should be 2
{{ 16 / 4 }} should be 4
{{ get( { "key1": "value1", "key2": "value2" }, "key2" ) }} should be value2
{{ get( numbers, "first" ) }} should be 5
{{ get( numbers, "second" ) }} should be 11
{{ get( numbers, "third" ) }} should be true
{{ get( numbers, "foo" ) }} should be null
{{ ( 2 + 2 ) * (2 + 2) }} should be 16
{{ 2 + " + 2 = 4" }} should be 2 + 2 = 4
{{ contains( "item1", { "item2": [ 2 ], "item1": "str" } ) }} should be true
{{ contains( 2, [ 1, 1, 1, 2, 3, 3 ] ) }} should be true
{{ contains( "ada", "abracadabra" ) }} should be true
{{ to_json( { "key1": "value1", "key2": [ 2, 4, 6] } ) }} should be { "key1": "value1", "key2": [ 2, 4, 6] }
{# Testing include tag #}
{% if true %}
{% include [ "inc_test.tpl" ] %}
{% else %}
{% include "Fake.tpl" %}
{% endif %}
Numbers:
{% for key,value in numbers %}
Key: {{ key }}, value: {{ value }}
{% endfor %}
{# Testing cache #}
{% cache 5000 "TestCache" %}{{ random(20, 100500) }}{% endcache %} should be {% cache 5000 "TestCache" %}{{ random(20, 100500) }}{% endcache %} cached
{% endblock %}
This text should not be here!
{% endextends %}