public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
update liquid

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2552 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Wed Dec 13 21:06:57 -0800 2006
commit  84518a8d11662e51478911bd90009fc9aa6864a4
tree    c6ab679799d3826f0a8abda7076e1223c54ffa95
parent  09a8453523fa99886afa4aea7fcb99a41595c494
...
1
2
3
 
4
5
6
...
20
21
22
23
 
24
25
26
...
63
64
65
66
 
67
68
69
...
1
2
3
4
5
6
7
...
21
22
23
 
24
25
26
27
...
64
65
66
 
67
68
69
70
0
@@ -1,6 +1,7 @@
0
 module Liquid
0
   
0
   class Block < Tag
0
+
0
     def parse(tokens)
0
       @nodelist ||= []
0
       @nodelist.clear
0
@@ -20,7 +21,7 @@ module Liquid
0
 
0
             # fetch the tag from registered blocks
0
             if tag = Template.tags[$1]
0
- @nodelist << tag.new($2, tokens)
0
+ @nodelist << tag.new($1, $2, tokens)
0
             else
0
               # this tag is not registered with the system
0
               # pass it to the current block for special handling or error reporting
0
@@ -63,7 +64,7 @@ module Liquid
0
     end
0
 
0
     def block_name
0
- self.class.name.scan(/\w+$/).first.downcase
0
+ @tag_name
0
     end
0
 
0
     def create_variable(token)
...
2
3
4
5
6
7
 
8
9
10
...
15
16
17
 
 
18
19
20
...
2
3
4
 
 
 
5
6
7
8
...
13
14
15
16
17
18
19
20
0
@@ -2,9 +2,7 @@ module Liquid
0
   class TableRow < Block
0
     Syntax = /(\w+)\s+in\s+(#{VariableSignature}+)/
0
     
0
- def initialize(markup, tokens)
0
- super
0
-
0
+ def initialize(tag_name, markup, tokens)
0
       if markup =~ Syntax
0
         @variable_name = $1
0
         @collection_name = $2
0
@@ -15,6 +13,8 @@ module Liquid
0
       else
0
         raise SyntaxError.new("Syntax Error in 'table_row loop' - Valid syntax: table_row [item] in [collection] cols=3")
0
       end
0
+
0
+ super
0
     end
0
     
0
     def render(context)
...
3
4
5
6
7
 
 
 
8
9
10
...
3
4
5
 
 
6
7
8
9
10
11
0
@@ -3,8 +3,9 @@ module Liquid
0
   class Tag
0
     attr_accessor :nodelist
0
     
0
- def initialize(markup, tokens)
0
- @markup = markup
0
+ def initialize(tag_name, markup, tokens)
0
+ @tag_name = tag_name
0
+ @markup = markup
0
       parse(tokens)
0
     end
0
     
...
2
3
4
5
 
6
7
8
9
10
11
 
 
12
13
14
...
2
3
4
 
5
6
7
8
9
10
11
12
13
14
15
16
0
@@ -2,13 +2,15 @@ module Liquid
0
   class Assign < Tag
0
     Syntax = /(#{VariableSignature}+)\s*=\s*(#{QuotedFragment}+)/
0
   
0
- def initialize(markup, tokens)
0
+ def initialize(tag_name, markup, tokens)
0
       if markup =~ Syntax
0
         @to = $1
0
         @from = $2
0
       else
0
         raise SyntaxError.new("Syntax Error in 'assign' - Valid syntax: assign [var] = [source]")
0
       end
0
+
0
+ super
0
     end
0
   
0
     def render(context)
...
2
3
4
5
 
6
7
8
9
10
11
 
 
12
13
14
...
2
3
4
 
5
6
7
 
8
9
10
11
12
13
14
15
0
@@ -2,13 +2,14 @@ module Liquid
0
   class Capture < Block
0
     Syntax = /(\w+)/
0
 
0
- def initialize(markup, tokens)
0
+ def initialize(tag_name, markup, tokens)
0
       if markup =~ Syntax
0
         @to = $1
0
- super
0
       else
0
         raise SyntaxError.new("Syntax Error in 'capture' - Valid syntax: capture [var]")
0
       end
0
+
0
+ super
0
     end
0
 
0
     def render(context)
...
3
4
5
6
 
7
8
9
...
3
4
5
 
6
7
8
9
0
@@ -3,7 +3,7 @@ module Liquid
0
     Syntax = /(#{QuotedFragment})/
0
     WhenSyntax = /(#{QuotedFragment})/
0
 
0
- def initialize(markup, tokens)
0
+ def initialize(tag_name, markup, tokens)
0
       @blocks = []
0
       
0
       if markup =~ Syntax
...
3
4
5
6
 
7
8
9
...
14
15
16
17
 
 
18
19
20
...
3
4
5
 
6
7
8
9
...
14
15
16
 
17
18
19
20
21
0
@@ -3,7 +3,7 @@ module Liquid
0
     SimpleSyntax = /#{QuotedFragment}/
0
     NamedSyntax = /(#{QuotedFragment})\s*\:\s*(.*)/
0
   
0
- def initialize(markup, tokens)
0
+ def initialize(tag_name, markup, tokens)
0
       case markup
0
       when NamedSyntax
0
         @variables = variables_from_string($2)
0
@@ -14,7 +14,8 @@ module Liquid
0
       else
0
         raise SyntaxError.new("Syntax Error in 'cycle' - Valid syntax: cycle [name :] var [, var2, var3 ...]")
0
       end
0
-
0
+
0
+ super
0
     end
0
   
0
     def render(context)
...
2
3
4
5
6
7
 
8
9
10
...
16
17
18
 
 
19
20
21
...
2
3
4
 
 
 
5
6
7
8
...
14
15
16
17
18
19
20
21
0
@@ -2,9 +2,7 @@ module Liquid
0
   class For < Block
0
     Syntax = /(\w+)\s+in\s+(#{VariableSignature}+)/
0
   
0
- def initialize(markup, tokens)
0
- super
0
-
0
+ def initialize(tag_name, markup, tokens)
0
       if markup =~ Syntax
0
         @variable_name = $1
0
         @collection_name = $2
0
@@ -16,6 +14,8 @@ module Liquid
0
       else
0
         raise SyntaxError.new("Syntax Error in 'for loop' - Valid syntax: for [item] in [collection]")
0
       end
0
+
0
+ super
0
     end
0
   
0
     def render(context)
...
2
3
4
5
 
 
6
7
8
...
2
3
4
 
5
6
7
8
9
0
@@ -2,7 +2,8 @@ module Liquid
0
   class If < Block
0
     Syntax = /(#{QuotedFragment})\s*([=!<>]+)?\s*(#{QuotedFragment})?/
0
     
0
- def initialize(markup, tokens)
0
+ def initialize(tag_name, markup, tokens)
0
+
0
       @blocks = []
0
       
0
       push_block('if', markup)
...
2
3
4
5
 
6
7
8
...
2
3
4
 
5
6
7
8
0
@@ -2,7 +2,7 @@ module Liquid
0
   class Include < Tag
0
     Syntax = /(#{QuotedFragment}+)(\s+(?:with|for)\s+(#{QuotedFragment}+))?/
0
   
0
- def initialize(markup, tokens)
0
+ def initialize(tag_name, markup, tokens)
0
       if markup =~ Syntax
0
 
0
         @template_name = $1
...
42
43
44
 
 
 
 
 
 
 
 
45
46
47
...
42
43
44
45
46
47
48
49
50
51
52
53
54
55
0
@@ -42,6 +42,14 @@ class VariableTest < Test::Unit::TestCase
0
     assert_equal 3, template.root.nodelist.size
0
   end
0
   
0
+ def test_with_custom_tag
0
+ Liquid::Template.register_tag("testtag", Block)
0
+
0
+ assert_nothing_thrown do
0
+ template = Liquid::Template.parse( "{% testtag %} {% endtesttag %}")
0
+ end
0
+ end
0
+
0
   private
0
   
0
   def block_types(nodelist)
...
6
7
8
9
 
10
11
12
...
6
7
8
 
9
10
11
12
0
@@ -6,7 +6,7 @@ class StandardTagTest < Test::Unit::TestCase
0
   
0
   
0
   def test_tag
0
- tag = Tag.new([], [])
0
+ tag = Tag.new('tag', [], [])
0
     assert_equal 'liquid::tag', tag.name
0
     assert_equal '', tag.render(Context.new)
0
   end

Comments

    No one has commented yet.