Skip to content

Commit eb4a01e

Browse files
committed
Bring Twig.xml up to date.
Added all filters, functions, etc. from the documentation. Made colors better. Added support for the string-interpolation syntax.
1 parent f2cb1f0 commit eb4a01e

File tree

2 files changed

+98
-35
lines changed

2 files changed

+98
-35
lines changed

Twig.xml

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,57 +5,57 @@
55
<Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
66
</Settings>
77
<KeywordLists>
8-
<Keywords name="Comments">00{# 01 02#} 03 04</Keywords>
8+
<Keywords name="Comments">00 01 02 03{# 04#}</Keywords>
99
<Keywords name="Numbers, prefix1"></Keywords>
1010
<Keywords name="Numbers, prefix2"></Keywords>
1111
<Keywords name="Numbers, extras1"></Keywords>
1212
<Keywords name="Numbers, extras2"></Keywords>
1313
<Keywords name="Numbers, suffix1"></Keywords>
1414
<Keywords name="Numbers, suffix2"></Keywords>
15-
<Keywords name="Numbers, range"></Keywords>
16-
<Keywords name="Operators1">- ! ( ) * , . / : ? [ ] | ~ + &lt; = &gt;</Keywords>
15+
<Keywords name="Numbers, range">..</Keywords>
16+
<Keywords name="Operators1">- ! ( ) * , / : ? [ ] | ~ + &lt; = &gt;</Keywords>
1717
<Keywords name="Operators2"></Keywords>
18-
<Keywords name="Folders in code1, open">block for if spaceless macro autoescape filter sandbox embed</Keywords>
18+
<Keywords name="Folders in code1, open"></Keywords>
1919
<Keywords name="Folders in code1, middle"></Keywords>
20-
<Keywords name="Folders in code1, close">endblock endfor endif endspaceless endmacro endautoescape endfilter endsandbox endembed</Keywords>
21-
<Keywords name="Folders in code2, open"></Keywords>
22-
<Keywords name="Folders in code2, middle"></Keywords>
23-
<Keywords name="Folders in code2, close"></Keywords>
20+
<Keywords name="Folders in code1, close"></Keywords>
21+
<Keywords name="Folders in code2, open">autoescape block filter embed for if macro sandbox spaceless verbatim</Keywords>
22+
<Keywords name="Folders in code2, middle">else</Keywords>
23+
<Keywords name="Folders in code2, close">endautoescape endblock endfilter endembed endfor endif endmacro endsandbox endspaceless endverbatim</Keywords>
2424
<Keywords name="Folders in comment, open"></Keywords>
2525
<Keywords name="Folders in comment, middle"></Keywords>
2626
<Keywords name="Folders in comment, close"></Keywords>
27-
<Keywords name="Keywords1">{{ }} {% %}</Keywords>
28-
<Keywords name="Keywords2">as do extends flush from import include raw set endset use is not true false and or b-and b-xor b-or % in else</Keywords>
29-
<Keywords name="Keywords3"></Keywords>
30-
<Keywords name="Keywords4"></Keywords>
31-
<Keywords name="Keywords5"></Keywords>
32-
<Keywords name="Keywords6"></Keywords>
33-
<Keywords name="Keywords7"></Keywords>
34-
<Keywords name="Keywords8"></Keywords>
35-
<Keywords name="Delimiters">&quot;&apos;0&quot;&apos;0</Keywords>
27+
<Keywords name="Keywords1">{% %} {{ }} { }</Keywords>
28+
<Keywords name="Keywords2">do&#x000D;&#x000A;extends&#x000D;&#x000A;flush&#x000D;&#x000A;from import as&#x000D;&#x000A;include&#x000D;&#x000A;set endset&#x000D;&#x000A;use&#x000D;&#x000A;filter&#x000D;&#x000A;</Keywords>
29+
<Keywords name="Keywords3">true false&#x000D;&#x000A;and not or&#x000D;&#x000A;is &apos;starts with&apos; &apos;ends with&apos; matches&#x000D;&#x000A;&apos;is constant&apos; &apos;is defined&apos; &apos;is divisible by&apos; &apos;is empty&apos; &apos;is even&apos; &apos;is odd&apos; &apos;is iterable&apos; &apos;is same as&apos;&#x000D;&#x000A;in</Keywords>
30+
<Keywords name="Keywords4">parent&#x000D;&#x000A;range&#x000D;&#x000A;attribute&#x000D;&#x000A;constant&#x000D;&#x000A;cycle&#x000D;&#x000A;date&#x000D;&#x000A;dump&#x000D;&#x000A;include&#x000D;&#x000A;max min&#x000D;&#x000A;random&#x000D;&#x000A;source&#x000D;&#x000A;template_from_string</Keywords>
31+
<Keywords name="Keywords5">null none</Keywords>
32+
<Keywords name="Keywords6">raw&#x000D;&#x000A;escape e&#x000D;&#x000A;url_encode&#x000D;&#x000A;striptags&#x000D;&#x000A;trim&#x000D;&#x000A;lower upper title capitalize&#x000D;&#x000A;convert_encoding&#x000D;&#x000A;format number_format&#x000D;&#x000A;replace&#x000D;&#x000A;join split&#x000D;&#x000A;nl2br</Keywords>
33+
<Keywords name="Keywords7">length&#x000D;&#x000A;abs&#x000D;&#x000A;round&#x000D;&#x000A;b-and b-xor b-or</Keywords>
34+
<Keywords name="Keywords8">date_modify&#x000D;&#x000A;batch&#x000D;&#x000A;keys&#x000D;&#x000A;first last&#x000D;&#x000A;merge&#x000D;&#x000A;default&#x000D;&#x000A;json_encode&#x000D;&#x000A;reverse&#x000D;&#x000A;slice&#x000D;&#x000A;sort</Keywords>
35+
<Keywords name="Delimiters">00&quot; 01\ 02&quot; 03&apos; 04\ 05&apos; 06#{ 07 08} 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23</Keywords>
3636
</KeywordLists>
3737
<Styles>
3838
<WordsStyle name="DEFAULT" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
39-
<WordsStyle name="COMMENTS" fgColor="B729D9" bgColor="0FFFFF" fontName="" fontStyle="0" nesting="0" />
40-
<WordsStyle name="LINE COMMENTS" fgColor="B729D9" bgColor="FFFF80" fontName="" fontStyle="0" nesting="0" />
41-
<WordsStyle name="NUMBERS" fgColor="FF8000" bgColor="FEFCF5" fontName="" fontStyle="0" nesting="0" />
42-
<WordsStyle name="KEYWORDS1" fgColor="008000" bgColor="FEFCF5" fontName="" fontStyle="1" nesting="0" />
43-
<WordsStyle name="KEYWORDS2" fgColor="FF8400" bgColor="FEFCF5" fontName="" fontStyle="0" nesting="0" />
44-
<WordsStyle name="KEYWORDS3" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
45-
<WordsStyle name="KEYWORDS4" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
46-
<WordsStyle name="KEYWORDS5" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
47-
<WordsStyle name="KEYWORDS6" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
48-
<WordsStyle name="KEYWORDS7" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
39+
<WordsStyle name="COMMENTS" fgColor="5B00B7" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
40+
<WordsStyle name="LINE COMMENTS" fgColor="5B00B7" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
41+
<WordsStyle name="NUMBERS" fgColor="0080C0" bgColor="FEFCF5" fontName="" fontStyle="0" nesting="0" />
42+
<WordsStyle name="KEYWORDS1" fgColor="535353" bgColor="FEFCF5" fontName="" fontStyle="1" nesting="0" />
43+
<WordsStyle name="KEYWORDS2" fgColor="DD7400" bgColor="FEFCF5" fontName="" fontStyle="0" nesting="0" />
44+
<WordsStyle name="KEYWORDS3" fgColor="A33235" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
45+
<WordsStyle name="KEYWORDS4" fgColor="BBBB00" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
46+
<WordsStyle name="KEYWORDS5" fgColor="FF0000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
47+
<WordsStyle name="KEYWORDS6" fgColor="005B00" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
48+
<WordsStyle name="KEYWORDS7" fgColor="0080C0" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
4949
<WordsStyle name="KEYWORDS8" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
50-
<WordsStyle name="OPERATORS" fgColor="008000" bgColor="FEFCF5" fontName="" fontStyle="1" nesting="0" />
51-
<WordsStyle name="FOLDER IN CODE1" fgColor="008000" bgColor="FFFFFF" fontName="" fontStyle="1" fontSize="8" nesting="0" />
52-
<WordsStyle name="FOLDER IN CODE2" fgColor="FF8400" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
50+
<WordsStyle name="OPERATORS" fgColor="DD7400" bgColor="FEFCF5" fontName="" fontStyle="1" nesting="0" />
51+
<WordsStyle name="FOLDER IN CODE1" fgColor="FF8040" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="10" nesting="0" />
52+
<WordsStyle name="FOLDER IN CODE2" fgColor="DD7400" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
5353
<WordsStyle name="FOLDER IN COMMENT" fgColor="FF8400" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
54-
<WordsStyle name="DELIMITERS1" fgColor="56DB3A" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
55-
<WordsStyle name="DELIMITERS2" fgColor="56DB3A" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
56-
<WordsStyle name="DELIMITERS3" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
57-
<WordsStyle name="DELIMITERS4" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
58-
<WordsStyle name="DELIMITERS5" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
54+
<WordsStyle name="DELIMITERS1" fgColor="005B00" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="4" />
55+
<WordsStyle name="DELIMITERS2" fgColor="005B00" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
56+
<WordsStyle name="DELIMITERS3" fgColor="535353" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="117702655" />
57+
<WordsStyle name="DELIMITERS4" fgColor="535353" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="117702655" />
58+
<WordsStyle name="DELIMITERS5" fgColor="535353" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="117702655" />
5959
<WordsStyle name="DELIMITERS6" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
6060
<WordsStyle name="DELIMITERS7" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />
6161
<WordsStyle name="DELIMITERS8" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" />

TwigHighlightingTests.tmpl

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{% for user in users %}
2+
* {{ user.name }}
3+
{% else %}
4+
No users have been found.
5+
{% endfor %}
6+
7+
{% extends "layout.html" %}
8+
9+
{% block content %}
10+
Content of the page...
11+
{% endblock %}
12+
13+
{# Comment
14+
Multiline #}
15+
16+
{% autoescape true %}
17+
{{ var }}
18+
{{ var|raw }} {# var won't be escaped #}
19+
{{ var|escape }} {# var won't be doubled-escaped #}
20+
{% endautoescape %}
21+
22+
{{ include('page.html', sandboxed = true) }}
23+
24+
{{ "foo #{1 + 2.2} baz" }}
25+
26+
{{ foo ? 'yes' : 'no' }}
27+
28+
{# as of Twig 1.12.0 #}
29+
{{ foo ?: 'no' }} {# is the same as #} {{ foo ? foo : 'no' }}
30+
{{ foo ? 'yes' }} {# is the same as #} {{ foo ? 'yes' : '' }}
31+
32+
{% set value = 'no spaces' %}
33+
{#- No leading/trailing whitespace -#}
34+
{%- if true is same as(true) -%}
35+
{{- value -}}
36+
{%- endif -%}
37+
38+
{% set foo %}
39+
<div id="pagination">
40+
...
41+
</div>
42+
{% endset %}
43+
44+
{% if 'Fabien' starts with 'F' %}
45+
{% endif %}
46+
47+
{% set foo = [1, {"foo": "bar"}] %}
48+
49+
{# keys as string #}
50+
{ 'foo': 'foo', 'bar': 'bar' }
51+
52+
{# keys as names (equivalent to the previous hash) -- as of Twig 1.5 #}
53+
{ foo: 'foo', bar: 'bar' }
54+
55+
{# keys as integer #}
56+
{ 2: 'foo', 4: 'bar' }
57+
58+
{# keys as expressions (the expression must be enclosed into parentheses) -- as of Twig 1.5 #}
59+
{ (1 + 1): 'foo', (a ~ 'b'): 'bar' }
60+
61+
["foo", "bar"] {# array #}
62+
63+
'It\'s good'

0 commit comments

Comments
 (0)