Skip to content

Commit fe3bc52

Browse files
authored
Liquid: Added empty keyword (#2997)
1 parent e997dd3 commit fe3bc52

File tree

3 files changed

+84
-2
lines changed

3 files changed

+84
-2
lines changed

components/prism-liquid.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ Prism.languages.liquid = {
3232
// https://github.com/Shopify/liquid/blob/698f5e0d967423e013f6169d9111bd969bd78337/lib/liquid/lexer.rb#L21
3333
'number': /\b\d+(?:\.\d+)?\b/,
3434
'operator': /[!=]=|<>|[<>]=?|[|?:=-]|\b(?:and|or|contains(?=\s))\b/,
35-
'punctuation': /[.,\[\]()]/
35+
'punctuation': /[.,\[\]()]/,
36+
'empty': {
37+
pattern: /\bempty\b/,
38+
alias: 'keyword'
39+
},
3640
};
3741

3842
Prism.hooks.add('before-tokenize', function (env) {

components/prism-liquid.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{% unless pages == empty %}
2+
<!-- This will only print if the page with handle "about" is not empty -->
3+
<h1>{{ pages.frontpage.not_empty_title }}</h1>
4+
<div>{{ pages.frontpage.content }}</div>
5+
{% endunless %}
6+
7+
----------------------------------------------------
8+
9+
[
10+
["liquid", [
11+
["delimiter", "{%"],
12+
["keyword", "unless"],
13+
" pages ",
14+
["operator", "=="],
15+
["empty", "empty"],
16+
["delimiter", "%}"]
17+
]],
18+
19+
["comment", "<!-- This will only print if the page with handle \"about\" is not empty -->"],
20+
21+
["tag", [
22+
["tag", [
23+
["punctuation", "<"],
24+
"h1"
25+
]],
26+
["punctuation", ">"]
27+
]],
28+
["liquid", [
29+
["delimiter", "{{"],
30+
" pages",
31+
["punctuation", "."],
32+
"frontpage",
33+
["punctuation", "."],
34+
"not_empty_title ",
35+
["delimiter", "}}"]
36+
]],
37+
["tag", [
38+
["tag", [
39+
["punctuation", "</"],
40+
"h1"
41+
]],
42+
["punctuation", ">"]
43+
]],
44+
45+
["tag", [
46+
["tag", [
47+
["punctuation", "<"],
48+
"div"
49+
]],
50+
["punctuation", ">"]
51+
]],
52+
["liquid", [
53+
["delimiter", "{{"],
54+
" pages",
55+
["punctuation", "."],
56+
"frontpage",
57+
["punctuation", "."],
58+
"content ",
59+
["delimiter", "}}"]
60+
]],
61+
["tag", [
62+
["tag", [
63+
["punctuation", "</"],
64+
"div"
65+
]],
66+
["punctuation", ">"]
67+
]],
68+
69+
["liquid", [
70+
["delimiter", "{%"],
71+
["keyword", "endunless"],
72+
["delimiter", "%}"]
73+
]]
74+
]
75+
76+
----------------------------------------------------
77+
78+
Test for the 'empty' keyword / special thing.

0 commit comments

Comments
 (0)