@@ -5,81 +5,13 @@ class Liquid < Scanner
5
5
6
6
register_for :liquid
7
7
8
- DIRECTIVE_KEYWORDS = /
9
- list|
10
- endlist|
11
- for|
12
- endfor|
13
- wrap|
14
- endwrap|
15
- if|
16
- endif|
17
- unless|
18
- endunless|
19
- elsif|
20
- assign|
21
- cycle|
22
- capture|
23
- end|
24
- capture|
25
- fill|
26
- iflist|
27
- endiflist|
28
- else|
29
- /x
8
+ DIRECTIVE_KEYWORDS = "list|endlist|for|endfor|wrap|endwrap|if|endif|unless|endunless|elsif|assign|cycle|capture|end|capture|fill|iflist|endiflist|else"
30
9
31
- DIRECTIVE_OPERATORS = /
32
- =|
33
- ==|
34
- !=|
35
- >|
36
- <|
37
- <=|
38
- >=|
39
- contains|
40
- /x
10
+ DIRECTIVE_OPERATORS = "=|==|!=|>|<|<=|>=|contains|"
41
11
42
- MATH = /
43
- =|
44
- ==|
45
- !=|
46
- >|
47
- <|
48
- <=|
49
- >|
50
- /x
12
+ MATH = "=|==|!=|>|<|<=|>|"
51
13
52
- FILTER_KEYWORDS = /
53
- date|
54
- capitalize|
55
- downcase|
56
- upcase|
57
- first|
58
- last|
59
- join|
60
- sort|
61
- map|
62
- size|
63
- escape|
64
- escape_once|
65
- strip_html|
66
- strip_newlines|
67
- newline_to_br|
68
- replace|
69
- replace_first|
70
- remove|
71
- remove_first|
72
- truncate|
73
- truncatewords|
74
- prepend|
75
- append|
76
- minus|
77
- plus|
78
- times|
79
- divided_by|
80
- split|
81
- modulo
82
- /x
14
+ FILTER_KEYWORDS = "date|capitalize|downcase|upcase|first|last|join|sort|map|size|escape|escape_once|strip_html|strip_newlines|newline_to_br|replace|replace_first|remove|remove_first|truncate|truncatewords|prepend|append|minus|plus|times|divided_by|split|modulo"
83
15
84
16
LIQUID_DIRECTIVE_BLOCK = /
85
17
{%
@@ -119,17 +51,16 @@ def scan_directive(encoder, options, match)
119
51
encoder . text_token match , :key
120
52
state = :liquid
121
53
scan_spaces ( encoder )
122
- #Replace with DIRECTIVES_KEYWORDS regex
123
- if match = scan ( /wrap|if|endif|endwrap / )
54
+ #This regex doesn't work and I don't know why
55
+ if match = scan ( /#{ DIRECTIVES_KEYWORDS } / )
124
56
encoder . text_token match , :directive
125
57
scan_spaces ( encoder )
126
58
if match =~ /if/
127
59
if match = scan ( /\w +\. ?\w */ )
128
60
encoder . text_token match , :variable
129
61
end
130
62
scan_spaces ( encoder )
131
- #Replace with MATH regex
132
- if match = scan ( /!=/ )
63
+ if match = scan ( /#{ MATH } / )
133
64
encoder . text_token match , :char
134
65
scan_spaces ( encoder )
135
66
end
@@ -150,10 +81,7 @@ def scan_directive(encoder, options, match)
150
81
def scan_output_filters ( encoder , options , match )
151
82
encoder . text_token match , :delimiter
152
83
scan_spaces ( encoder )
153
- #Replace with FILTER_KEYWORDS regex
154
- testx = /replace_first|prepend/
155
- if directive = scan ( /#{ testx } / )
156
- #if directive = scan(/#{FILTER_KEYWORDS}/)
84
+ if directive = scan ( /#{ FILTER_KEYWORDS } / )
157
85
encoder . text_token directive , :directive
158
86
end
159
87
if delimiter = scan ( /:/ )
0 commit comments