@@ -9,14 +9,14 @@ class Liquid < Scanner
9
9
10
10
DIRECTIVE_OPERATORS = "=|==|!=|>|<|<=|>=|contains"
11
11
12
- MATH = "=|== |!=|>|<|<= |>"
12
+ MATH = "==|= |!=|>|<=|< |>"
13
13
14
14
FILTER_KEYWORDS = "date|capitalize|downcase|upcase|first|last|join|sort|map|size|escape_once|escape|strip_html|strip_newlines|newline_to_br|replace_first|replace|remove_first|remove|truncate|truncatewords|prepend|append|minus|plus|times|divided_by|split|modulo"
15
15
16
16
LIQUID_DIRECTIVE_BLOCK = /
17
- {%
17
+ {{1,2} %
18
18
(.*?)
19
- %}
19
+ %}{1,2}
20
20
/x
21
21
22
22
def setup
@@ -75,7 +75,7 @@ def scan_directive(encoder, options, match)
75
75
end
76
76
scan_selector ( encoder , options , match )
77
77
scan_spaces ( encoder )
78
- if match = scan ( /%}/ )
78
+ if match = scan ( /%}{1,2} / )
79
79
encoder . text_token match , :tag
80
80
state = :initial
81
81
end
@@ -111,7 +111,7 @@ def scan_output(encoder, options, match)
111
111
scan_output_filters ( encoder , options , match )
112
112
end
113
113
scan_spaces ( encoder )
114
- if match = scan ( /}}/ )
114
+ if match = scan ( /}{2,3 }/ )
115
115
encoder . text_token match , :tag
116
116
end
117
117
state = :initial
@@ -122,7 +122,7 @@ def scan_tokens(encoder, options)
122
122
state = :initial
123
123
124
124
until eos?
125
- if ( match = scan_until ( /(?=({{|{ %))/ ) || scan_rest ) and not match . empty? and state != :liquid
125
+ if ( match = scan_until ( /(?=({{2,3}|{{1,2} %))/ ) || scan_rest ) and not match . empty? and state != :liquid
126
126
Rails . logger . debug "DEBUG: HTML scanning: #{ match } "
127
127
if match =~ /^"|^'/
128
128
#match = match.sub /^"|^'/, ''
@@ -132,9 +132,9 @@ def scan_tokens(encoder, options)
132
132
end
133
133
state = :initial
134
134
scan_spaces ( encoder )
135
- elsif match = scan ( /{%/ )
135
+ elsif match = scan ( /{{1,2} %/ )
136
136
scan_directive ( encoder , options , match )
137
- elsif match = scan ( /{{/ )
137
+ elsif match = scan ( /{{2,3} / )
138
138
scan_output ( encoder , options , match )
139
139
else
140
140
raise "Else-case reached. State: #{ state . to_s } ."
0 commit comments