-
-
Notifications
You must be signed in to change notification settings - Fork 67
/
TwigHighlightingTests.tmpl
72 lines (50 loc) · 1.55 KB
/
TwigHighlightingTests.tmpl
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
{% for user in users %}
* {{ user.name }}
{% else %}
No users have been found.
{% endfor %}
{% extends "layout.html" %}
{% block content %}
Content of the page...
{% endblock %}
{# Comment
Multiline #}
{{ "I like %S and %s."|format(foo, "bar") }}
{% autoescape true %}
{{ var }}
{{ var|raw }} {# var won't be escaped #}
{{ var|escape }} {# var won't be doubled-escaped #}
{% endautoescape %}
{{ include('page.html', sandboxed = true) }}
{{ "foo #{1 + 2.2} baz" }}
{{ 'foo #{1 + 2.2} baz' }} {# string interpolation isn't supported for single quoted (by twig) #}
{{ foo ? 'yes' : 'no' }}
{# as of Twig 1.12.0 #}
{{ foo ?: 'no' }} {# is the same as #} {{ foo ? foo : 'no' }}
{{ foo ? 'yes' }} {# is the same as #} {{ foo ? 'yes' : '' }}
{% set value = 'no spaces' %}
{#- No leading/trailing whitespace -#}
{%- if true is same as(true) -%}
{{- value -}}
{%- elseif true -%}
{{- value -}}
{%- endif -%}
{% set foo %}
<div id="pagination">
...
</div>
{% endset %}
{% if 'Fabien' starts with 'F' %}
{% endif %}
{% set foo = [1, {"foo": "bar"}] %}
{# keys as string #}
{% { 'foo': 'foo', 'bar': 'bar' } %}
{# keys as names (equivalent to the previous hash) -- as of Twig 1.5 #}
{% { foo: 'foo', bar: 'bar' } %}
{# keys as integer #}
{% { 2: 'foo', 4: 'bar' } %}
{# keys as expressions (the expression must be enclosed into parentheses) -- as of Twig 1.5 #}
{% { (1 + 1): 'foo', (a ~ 'b'): 'bar' } %}
{% ["foo", "bar"] {# array #} %}
{% 'It\'s good' %}
<button class="btn subscribe col-md-offset-3">S'inscrire</button>