public
Rubygem
Description: Liquid markup language. Save, customer facing template language for flexible web apps.
Homepage: http://www.liquidmarkup.org
Clone URL: git://github.com/tobi/liquid.git
Click here to lend your support to: liquid and make a donation at www.pledgie.com !
adjusted parsing regex for syntax quirk
Emmanuel Oga (author)
Tue Jul 08 08:54:52 -0700 2008
commit  3eddf5fb9e708cf26603d1f535a60e2e5ae0fc65
tree    61f0e314c49a8c47640654dad4049676573812e5
parent  6dd4f716f824b66680976f564cfc85615283fe9e
...
35
36
37
38
 
 
 
39
40
41
...
35
36
37
 
38
39
40
41
42
43
0
@@ -35,7 +35,9 @@ module Liquid
0
   VariableIncompleteEnd       = /\}\}?/
0
   QuotedFragment              = /"[^"]+"|'[^']+'|[^\s,|]+/
0
   TagAttributes               = /(\w+)\s*\:\s*(#{QuotedFragment})/
0
-  TemplateParser              = /(#{TagStart}.*?#{TagEnd}|#{VariableStart}.*?#{VariableIncompleteEnd})/
0
+  AnyStartingTag              = /\{\{|\{\%/
0
+  PartialTemplateParser       = /#{TagStart}.*?#{TagEnd}|#{VariableStart}.*?#{VariableIncompleteEnd}/
0
+  TemplateParser              = /(#{PartialTemplateParser}|#{AnyStartingTag})/
0
   VariableParser              = /\[[^\]]+\]|#{VariableSegment}+/
0
 end
0
 
...
18
19
20
 
 
 
 
 
 
 
 
 
 
 
21
22
23
...
26
27
28
 
29
30
...
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
...
37
38
39
40
41
42
0
@@ -18,6 +18,17 @@ class ParsingQuirksTest < Test::Unit::TestCase
0
     end
0
   end
0
   
0
+  def test_raise_on_label_and_no_close_bracets
0
+    assert_raise(SyntaxError) do
0
+      Template.parse("TEST {{ ")
0
+    end
0
+  end    
0
+  
0
+  def test_raise_on_label_and_no_close_bracets_percent
0
+    assert_raise(SyntaxError) do
0
+      Template.parse("TEST {% ")
0
+    end
0
+  end
0
   
0
   def test_error_on_empty_filter
0
     assert_nothing_raised do
0
@@ -26,4 +37,5 @@ class ParsingQuirksTest < Test::Unit::TestCase
0
       Template.parse("{{|test|}}")      
0
     end
0
   end
0
+  
0
 end
0
\ No newline at end of file

Comments