forked from trivago/prettier-plugin-twig-melody
-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathoperators.snap.twig
86 lines (82 loc) · 1.56 KB
/
operators.snap.twig
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
{{ a b-and b }}
{{ a b-or b }}
{{ a b-xor b }}
{{ a or b }}
{{ a and b }}
{{ a == b }}
{{ a != b }}
{{ a < b }}
{{ a > b }}
{{ a >= b }}
{{ a <= b }}
{{ a in b }}
{{ a not in b }}
{{ a matches b }}
{{ a matches '^foo' }}
{{ a starts with b }}
{{ a ends with b }}
{{ a..b }}
{{ a + b }}
{{ a - b }}
{{ a ~ b }}
{{ a * b }}
{{ a / b }}
{{ a % b }}
{{ a ** b }}
{{ a ? b }}
{{ a ? : b }}
{{ a ?? b }}
{{ a <=> b }}
{# Empty coalesce operator, extension for CraftCMS #}
{# Ref: https://plugins.craftcms.com/empty-coalesce #}
{{ a ??? b }}
{{ a is divisible by(b) }}
{{ a is not divisible by(b) }}
{{ a is defined }}
{{ a is not defined }}
{{ isEmpty is empty }}
{{ a is not empty }}
{{ a is even }}
{{ a is not even }}
{{ a is iterable }}
{{ a is not iterable }}
{{ a is null }}
{{ a is not null }}
{{ a is odd }}
{{ a is not odd }}
{{ a is same as(b) }}
{{ a is not same as(b) }}
{{ a is not same as(
banana,
apple,
orange,
lemonade,
kiwi,
coconut,
pineapple,
pomegrenade
) }}
{# Craft CMS specific feature #}
{# Ref: https://craftcms.com/docs/5.x/reference/twig/tests.html#instance-of #}
{% if
element is instance of('craft\\elements\\Entry')
or element is instance of(
constant('Namespace\\Classname::CONSTANT_NAME')
) %}
<h1>{{ entry.title }}</h1>
{% endif %}
{{ dump(test) }}
{{ range(2, 3)|sort|join(',') }}
{{ range(3)|sort|join(',') }}
{{ range(2, 3, 2)|sort|join(',') }}
{{ test|raw }}
{{ 2.4|abs }}
{{
{
a: 'b'
}
|json_encode
|trim
}}
{{ [2, 3]|length }}
{{ 'test.foo'|split('.') }}