UNPKG

1.06 kBJavaScriptView Raw
1Prism.languages.twig = {
2 'comment': /\{#[\s\S]*?#\}/,
3 'tag': {
4 pattern: /\{\{[\s\S]*?\}\}|\{%[\s\S]*?%\}/,
5 inside: {
6 'ld': {
7 pattern: /^(?:\{\{-?|\{%-?\s*\w+)/,
8 inside: {
9 'punctuation': /^(?:\{\{|\{%)-?/,
10 'keyword': /\w+/
11 }
12 },
13 'rd': {
14 pattern: /-?(?:%\}|\}\})$/,
15 inside: {
16 'punctuation': /.+/
17 }
18 },
19 'string': {
20 pattern: /("|')(?:\\.|(?!\1)[^\\\r\n])*\1/,
21 inside: {
22 'punctuation': /^['"]|['"]$/
23 }
24 },
25 'keyword': /\b(?:even|if|odd)\b/,
26 'boolean': /\b(?:true|false|null)\b/,
27 'number': /\b0x[\dA-Fa-f]+|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][-+]?\d+)?/,
28 'operator': [
29 {
30 pattern: /(\s)(?:and|b-and|b-xor|b-or|ends with|in|is|matches|not|or|same as|starts with)(?=\s)/,
31 lookbehind: true
32 },
33 /[=<>]=?|!=|\*\*?|\/\/?|\?:?|[-+~%|]/
34 ],
35 'property': /\b[a-zA-Z_]\w*\b/,
36 'punctuation': /[()\[\]{}:.,]/
37 }
38 },
39
40 // The rest can be parsed as HTML
41 'other': {
42 // We want non-blank matches
43 pattern: /\S(?:[\s\S]*\S)?/,
44 inside: Prism.languages.markup
45 }
46};
47
\No newline at end of file