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 (beware test failures)

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2529 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Wed Dec 06 19:03:39 -0800 2006
commit  1245c3a01d4ff7f784fed6790becd72120a13f13
tree    cddb29f3717b42a8ca76b5822e2937dc493393be
parent  b4cffbb0394cd454b383b2afd0e667297aef54d6
...
1
2
3
4
5
6
7
 
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 
 
 
24
25
26
...
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
 
 
 
 
 
 
 
 
133
...
1
2
3
 
 
 
 
4
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
7
8
9
10
11
...
14
15
16
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
18
19
20
21
22
23
24
25
0
@@ -1,26 +1,11 @@
0
 #!/usr/bin/env ruby
0
 require 'rubygems'
0
 require 'rake'
0
-require 'rake/testtask'
0
-require 'rake/rdoctask'
0
-require 'rake/gempackagetask'
0
-require 'rake/contrib/rubyforgepublisher'
0
+require 'hoe'
0
 
0
-PKG_VERSION = "1.5.0"
0
-PKG_NAME = "liquid"
0
-PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
0
-
0
-PKG_FILES = FileList[
0
- "lib/**/*", "test/**/*", "example/**/*" "[A-Z]*", "Rakefile", "init.rb"
0
-].exclude(/\bCVS\b|~$|\.svn/)
0
-
0
-desc "Default Task"
0
-task :default => [ :test ]
0
-
0
-desc "Delete tar.gz / zip / rdoc"
0
-task :cleanup => [ :rm_packages, :clobber_rdoc ]
0
-
0
-# Run the unit tests
0
+PKG_VERSION = "1.7.0"
0
+PKG_NAME = "liquid"
0
+PKG_DESC = "A secure non evaling end user template engine with aesthetic markup."
0
 
0
 Rake::TestTask.new(:test) do |t|
0
   t.libs << "lib"
0
@@ -29,104 +14,11 @@ Rake::TestTask.new(:test) do |t|
0
   t.verbose = false
0
 end
0
 
0
-task :install => [:package] do
0
- `gem install pkg/#{PKG_FILE_NAME}.gem`
0
-end
0
-
0
-task :coverage do
0
- system("rcov test/*.rb -T --sort coverage")
0
-end
0
-
0
-task :syntax do
0
- filelist = Dir.glob('**/*.rb')
0
- filelist.each do |file|
0
- output = `ruby -c #{file}`
0
- unless output =~ /Syntax OK/
0
- puts "#{file}:"
0
- puts " #{output}"
0
- return
0
- end
0
- end
0
- puts 'Syntax OK'
0
-end
0
-
0
-# Genereate the RDoc documentation
0
-
0
-Rake::RDocTask.new { |rdoc|
0
- rdoc.rdoc_dir = 'doc'
0
- rdoc.title = "Liquid templates library"
0
- rdoc.options << '--line-numbers --inline-source'
0
- rdoc.rdoc_files.include('README')
0
- rdoc.rdoc_files.include('lib/**/*.rb')
0
-}
0
-
0
-task :lines do
0
- lines = 0
0
- codelines = 0
0
- Dir.foreach("lib") { |file_name|
0
- next unless file_name =~ /.*rb/
0
-
0
- f = File.open("lib/" + file_name)
0
-
0
- while line = f.gets
0
- lines += 1
0
- next if line =~ /^\s*$/
0
- next if line =~ /^\s*#/
0
- codelines += 1
0
- end
0
- }
0
- puts "Lines #{lines}, LOC #{codelines}"
0
-end
0
-
0
-
0
-# Publish beta gem
0
-desc "Publish the gem on leetsoft"
0
-task :publish => [:rdoc, :package] do
0
- Rake::SshFilePublisher.new("leetsoft.com", "dist/pkg", "pkg", "#{PKG_FILE_NAME}.zip").upload
0
- Rake::SshFilePublisher.new("leetsoft.com", "dist/pkg", "pkg", "#{PKG_FILE_NAME}.tgz").upload
0
- Rake::SshFilePublisher.new("leetsoft.com", "dist/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
0
-
0
- `ssh tobi@leetsoft.com "mkdir -p dist/api/#{PKG_NAME}"`
0
- Rake::SshDirPublisher.new("leetsoft.com", "dist/api/#{PKG_NAME}", "doc").upload
0
- `ssh tobi@leetsoft.com './gemupdate'`
0
- `rm -rf pkg/`
0
- `rm -rf doc/`
0
-end
0
-
0
-
0
-spec = Gem::Specification.new do |s|
0
- s.name = PKG_NAME
0
- s.version = PKG_VERSION
0
- s.summary = "A secure non evaling end user template engine with aesthetic markup"
0
- s.has_rdoc = true
0
- s.files = PKG_FILES
0
-
0
- s.require_path = 'lib'
0
- s.autorequire = 'liquid'
0
- s.author = "Tobias Luetke"
0
- s.email = "tobi@leetsoft.com"
0
- s.homepage = "http://dist.leetsoft.com/api/liquid"
0
-end
0
-
0
-Rake::GemPackageTask.new(spec) do |p|
0
- p.gem_spec = spec
0
- p.need_tar = true
0
- p.need_zip = true
0
-end
0
-
0
-# --- Ruby forge release manager by florian gross -------------------------------------------------
0
-RUBY_FORGE_PROJECT = 'liquid'
0
-RUBY_FORGE_USER = 'xal'
0
-
0
-RELEASE_NAME = "REL-#{PKG_VERSION}"
0
-RUBY_FORGE_GROUPID = "1069"
0
-RUBY_FORGE_PACKAGEID = "1255"
0
-
0
-desc "Publish the release files to RubyForge."
0
-task :release => [:gem, :package] do
0
-# files = ["zip", "tgz"].map { |ext| "pkg/#{PKG_FILE_NAME}.#{ext}" }
0
-
0
- system("rubyforge login")
0
- system("rubyforge add_release #{PKG_NAME} #{PKG_NAME} 'REL #{PKG_VERSION}' pkg/#{PKG_NAME}-#{PKG_VERSION}.zip")
0
- system("rubyforge add_release #{PKG_NAME} #{PKG_NAME} 'REL #{PKG_VERSION}' pkg/#{PKG_NAME}-#{PKG_VERSION}.tgz")
0
-end
0
+Hoe.new(PKG_NAME, PKG_VERSION) do |p|
0
+ p.rubyforge_name = PKG_NAME
0
+ p.summary = PKG_DESC
0
+ p.description = nil
0
+ p.author = "Tobias Luetke"
0
+ p.email = "tobi@leetsoft.com"
0
+ p.url = "http://home.leetsoft.com/liquid"
0
+end
0
\ No newline at end of file
...
3
4
5
6
 
7
8
9
...
3
4
5
 
6
7
8
9
0
@@ -3,7 +3,7 @@ require 'rexml/document'
0
 
0
 require File.dirname(__FILE__) + '/../../lib/liquid'
0
 require File.dirname(__FILE__) + '/liquid_servlet'
0
-require File.dirname(__FILE__) + '/test_servlet'
0
+require File.dirname(__FILE__) + '/example_servlet'
0
 
0
 # Setup webrick
0
 server = WEBrick::HTTPServer.new( :Port => ARGV[1] || 3000 )
...
28
29
30
31
32
 
 
33
34
35
...
28
29
30
 
 
31
32
33
34
35
0
@@ -28,8 +28,8 @@ module Liquid
0
   VariableAttributeSeparator = '.'
0
   TagStart = /\{\%/
0
   TagEnd = /\%\}/
0
- VariableSignature = /[\w\-\.\[\]]/
0
- VariableSegment = /[\w\-]/
0
+ VariableSignature = /\(?[\w\-\.\[\]]\)?/
0
+ VariableSegment = /[\w\-]\??/
0
   VariableStart = /\{\{/
0
   VariableEnd = /\}\}/
0
   QuotedFragment = /"[^"]+"|'[^']+'|[^\s,|]+/
...
76
77
78
79
 
80
81
82
...
92
93
94
95
 
96
97
98
...
76
77
78
 
79
80
81
82
...
92
93
94
 
95
96
97
98
0
@@ -76,7 +76,7 @@ module Liquid
0
     def render(context)
0
       render_all(@nodelist, context)
0
     end
0
-
0
+
0
     protected
0
 
0
     def assert_missing_delimitation!
0
@@ -92,7 +92,7 @@ module Liquid
0
             token.to_s
0
           end
0
         rescue Exception => e
0
- context.template.handle_error(e)
0
+ context.handle_error(e)
0
         end
0
           
0
       end
...
1
2
3
4
5
6
7
8
9
10
 
 
 
 
 
 
 
 
 
 
 
11
12
13
14
 
 
 
15
16
17
18
 
 
 
19
20
21
22
 
 
 
23
24
25
26
 
 
 
27
28
 
29
30
31
32
33
34
35
 
 
 
 
 
 
 
36
37
38
39
40
41
42
43
 
 
 
 
 
 
44
45
46
47
48
 
 
49
50
 
51
52
53
54
55
 
 
 
 
56
57
 
58
59
60
61
62
63
64
65
66
67
68
69
 
 
 
 
 
 
 
 
 
 
 
70
71
72
73
74
75
76
77
 
 
 
 
 
 
 
78
79
 
80
81
82
83
 
 
 
84
85
86
 
 
 
87
 
88
89
...
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
 
 
 
13
14
15
16
 
 
 
17
18
19
20
 
 
 
21
22
23
24
 
 
 
25
26
27
28
 
29
30
 
 
 
 
 
 
31
32
33
34
35
36
37
38
 
39
 
 
 
 
 
40
41
42
43
44
45
46
 
47
 
 
48
49
50
 
51
52
 
 
 
 
53
54
55
56
57
 
58
59
 
 
 
 
 
 
 
 
 
 
 
60
61
62
63
64
65
66
67
68
69
70
71
 
 
 
 
 
 
 
72
73
74
75
76
77
78
79
 
80
81
 
 
 
82
83
84
85
 
 
86
87
88
89
90
91
92
0
@@ -1,88 +1,91 @@
0
-# Container for liquid nodes which conveniently wrapps decision making logic
0
-#
0
-# Example:
0
-#
0
-# c = Condition.new('1', '==', '1')
0
-# c.evaluate #=> true
0
-#
0
-class Condition
0
- attr_reader :attachment
0
- attr_accessor :left, :operator, :right
0
+module Liquid
0
+ # Container for liquid nodes which conveniently wrapps decision making logic
0
+ #
0
+ # Example:
0
+ #
0
+ # c = Condition.new('1', '==', '1')
0
+ # c.evaluate #=> true
0
+ #
0
+ class Condition
0
+ attr_reader :attachment
0
+ attr_accessor :left, :operator, :right
0
   
0
- def initialize(left = nil, operator = nil, right = nil)
0
- @left, @operator, @right = left, operator, right
0
- end
0
+ def initialize(left = nil, operator = nil, right = nil)
0
+ @left, @operator, @right = left, operator, right
0
+ end
0
     
0
- def evaluate(context = Context.new)
0
- interpret_condition(left, right, operator, context)
0
- end
0
+ def evaluate(context = Context.new)
0
+ interpret_condition(left, right, operator, context)
0
+ end
0
   
0
- def attach(attachment)
0
- @attachment = attachment
0
- end
0
+ def attach(attachment)
0
+ @attachment = attachment
0
+ end
0
   
0
- def else?
0
- false
0
- end
0
+ def else?
0
+ false
0
+ end
0
     
0
- private
0
+ private
0
   
0
- def equal_variables(left, right)
0
- if left.is_a?(Symbol)
0
- if right.respond_to?(left)
0
- return right.send(left.to_s)
0
- else
0
- return nil
0
+ def equal_variables(left, right)
0
+ if left.is_a?(Symbol)
0
+ if right.respond_to?(left)
0
+ return right.send(left.to_s)
0
+ else
0
+ return nil
0
+ end
0
       end
0
- end
0
 
0
- if right.is_a?(Symbol)
0
- if left.respond_to?(right)
0
- return left.send(right.to_s)
0
- else
0
- return nil
0
+ if right.is_a?(Symbol)
0
+ if left.respond_to?(right)
0
+ return left.send(right.to_s)
0
+ else
0
+ return nil
0
+ end
0
       end
0
- end
0
 
0
- left == right
0
- end
0
+ left == right
0
+ end
0
 
0
- def interpret_condition(left, right, op, context)
0
+ def interpret_condition(left, right, op, context)
0
 
0
- # If the operator is empty this means that the decision statement is just
0
- # a single variable. We can just poll this variable from the context and
0
- # return this as the result.
0
- return context[left] if op == nil
0
+ # If the operator is empty this means that the decision statement is just
0
+ # a single variable. We can just poll this variable from the context and
0
+ # return this as the result.
0
+ return context[left] if op == nil
0
 
0
- left, right = context[left], context[right]
0
+ left, right = context[left], context[right]
0
 
0
- operation = case op
0
- when '==' then return equal_variables(left, right)
0
- when '!=' then return !equal_variables(left, right)
0
- when '<>' then return !equal_variables(left, right)
0
- when '>' then :>
0
- when '<' then :<
0
- when '>=' then :>=
0
- when '<=' then :<=
0
- else
0
- raise ArgumentError.new("Error in tag '#{name}' - Unknown operator #{op}")
0
- end
0
+ operation = case op
0
+ when '==' then return equal_variables(left, right)
0
+ when '!=' then return !equal_variables(left, right)
0
+ when '<>' then return !equal_variables(left, right)
0
+ when '>' then :>
0
+ when '<' then :<
0
+ when '>=' then :>=
0
+ when '<=' then :<=
0
+ else
0
+ raise ArgumentError.new("Error in tag '#{name}' - Unknown operator #{op}")
0
+ end
0
 
0
- if left.respond_to?(operation) and right.respond_to?(operation)
0
- left.send(operation, right)
0
- else
0
- nil
0
- end
0
- end
0
-end
0
+ if left.respond_to?(operation) and right.respond_to?(operation)
0
+ left.send(operation, right)
0
+ else
0
+ nil
0
+ end
0
+ end
0
+ end
0
 
0
-class ElseCondition < Condition
0
+ class ElseCondition < Condition
0
       
0
- def else?
0
- true
0
- end
0
+ def else?
0
+ true
0
+ end
0
   
0
- def evaluate(context)
0
- true
0
+ def evaluate(context)
0
+ true
0
+ end
0
   end
0
+
0
 end
0
\ No newline at end of file
...
17
18
19
20
 
21
22
23
24
25
 
 
 
 
 
 
26
27
28
29
30
31
32
33
 
34
35
36
...
38
39
40
41
42
43
 
44
45
46
 
 
 
 
 
 
 
 
 
 
 
47
48
49
...
115
116
117
118
 
119
120
121
...
123
124
125
126
127
128
129
130
...
134
135
136
 
 
 
 
137
138
139
140
141
 
142
143
144
...
148
149
150
151
 
 
152
153
154
...
166
167
168
169
 
170
171
172
...
177
178
179
180
181
 
 
 
182
183
184
...
17
18
19
 
20
21
 
 
 
 
22
23
24
25
26
27
28
29
30
 
 
 
 
 
31
32
33
34
...
36
37
38
 
 
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
...
123
124
125
 
126
127
128
129
...
131
132
133
 
 
134
135
136
...
140
141
142
143
144
145
146
147
148
149
150
 
151
152
153
154
...
158
159
160
 
161
162
163
164
165
...
177
178
179
 
180
181
182
183
...
188
189
190
 
 
191
192
193
194
195
196
0
@@ -17,20 +17,18 @@ module Liquid
0
   # context['bob'] #=> nil class Context
0
   class Context
0
     attr_reader :scopes
0
- attr_reader :template
0
+ attr_reader :errors, :registers
0
     
0
- def initialize(template)
0
- @template = template
0
- @scopes = [template.assigns]
0
- end
0
+ def initialize(assigns = {}, registers = {}, rethrow_errors = false)
0
+ @scopes = [(assigns || {})]
0
+ @registers = registers
0
+ @errors = []
0
+ @rethrow_errors = rethrow_errors
0
+ end
0
            
0
     def strainer
0
       @strainer ||= Strainer.create(self)
0
- end
0
-
0
- def registers
0
- @template.registers
0
- end
0
+ end
0
                
0
     # adds filters to this context.
0
     # this does not register the filters with the main Template object. see <tt>Template.register_filter</tt>
0
@@ -38,12 +36,22 @@ module Liquid
0
     def add_filters(filters)
0
       filters = [filters].flatten.compact
0
       
0
- raise ArgumentError, "Expected module but got: #{filter_module.class}" unless filters.all? { |f| f.is_a?(Module)}
0
-
0
       filters.each do |f|
0
+ raise ArgumentError, "Expected module but got: #{f.class}" unless f.is_a?(Module)
0
         strainer.extend(f)
0
       end
0
     end
0
+
0
+ def handle_error(e)
0
+ errors.push(e)
0
+ raise if @rethrow_errors
0
+
0
+ case e
0
+ when SyntaxError then "Liquid syntax error: #{e.message}"
0
+ else "Liquid error: #{e.message}"
0
+ end
0
+ end
0
+
0
                               
0
     def invoke(method, *args)
0
       if strainer.respond_to?(method)
0
@@ -115,7 +123,7 @@ module Liquid
0
     #
0
     def resolve(key)
0
       case key
0
- when nil
0
+ when nil, 'nil', 'null', ''
0
         nil
0
       when 'true'
0
         true
0
@@ -123,8 +131,6 @@ module Liquid
0
         false
0
       when 'empty'
0
         :empty?
0
- when 'nil', 'null'
0
- nil
0
       # Single quoted strings
0
       when /^'(.*)'$/
0
         $1.to_s
0
@@ -134,11 +140,15 @@ module Liquid
0
       # Integer and floats
0
       when /^(\d+)$/
0
         $1.to_i
0
+ # Ranges
0
+ when /^\((\S+)\.\.(\S+)\)$/
0
+ (resolve($1).to_i..resolve($2).to_i)
0
+ # Floats
0
       when /^(\d[\d\.]+)$/
0
         $1.to_f
0
       else
0
         variable(key)
0
- end
0
+ end
0
     end
0
     
0
     # fetches an object starting at the local scope and then moving up
0
@@ -148,7 +158,8 @@ module Liquid
0
         if scope.has_key?(key)
0
           variable = scope[key]
0
           variable = scope[key] = variable.call(self) if variable.is_a?(Proc)
0
- variable.context = self if variable.respond_to?(:context=)
0
+ variable = variable.to_liquid
0
+ variable.context = self if variable.respond_to?(:context=)
0
           return variable
0
         end
0
       end
0
@@ -166,7 +177,7 @@ module Liquid
0
     def variable(markup)
0
       parts = markup.scan(VariableParser)
0
       
0
- if object = find_variable(parts.shift).to_liquid
0
+ if object = find_variable(parts.shift)
0
             
0
         parts.each do |part|
0
 
0
@@ -177,8 +188,9 @@ module Liquid
0
           if object.respond_to?(:has_key?) and object.has_key?(part)
0
           
0
             # if its a proc we will replace the entry in the hash table with the proc
0
- object[part] = object[part].call(self) if object[part].is_a?(Proc) and object.respond_to?(:[]=)
0
- object = object[part].to_liquid
0
+ res = object[part]
0
+ res = object[part] = res.call(self) if res.is_a?(Proc) and object.respond_to?(:[]=)
0
+ object = res.to_liquid
0
 
0
           # Array
0
           elsif object.respond_to?(:fetch) and part =~ /^\d+$/
...
1
2
3
4
 
5
6
7
8
9
10
 
11
12
13
14
15
16
 
17
18
19
20
21
22
 
23
24
25
26
27
28
 
29
30
31
32
33
34
 
35
36
37
38
39
40
 
41
42
43
44
45
46
 
47
48
49
50
 
51
52
53
54
 
55
56
57
...
1
2
3
 
4
5
6
7
8
9
 
10
11
12
13
14
15
 
16
17
18
19
20
21
 
22
23
24
25
26
27
 
28
29
30
31
32
33
 
34
35
36
37
38
39
 
40
41
42
43
44
45
 
46
47
48
49
 
50
51
52
53
 
54
55
56
57
0
@@ -1,56 +1,56 @@
0
 require 'time'
0
 require 'date'
0
 
0
-class String
0
+class String # :nodoc:
0
   def to_liquid
0
     self
0
   end
0
 end
0
 
0
-class Array
0
+class Array # :nodoc:
0
   def to_liquid
0
     self
0
   end
0
 end
0
 
0
-class Hash
0
+class Hash # :nodoc:
0
   def to_liquid
0
     self
0
   end
0
 end
0
 
0
-class Numeric
0
+class Numeric # :nodoc:
0
   def to_liquid
0
     self
0
   end
0
 end
0
 
0
-class Time
0
+class Time # :nodoc:
0
   def to_liquid
0
     self
0
   end
0
 end
0
 
0
-class DateTime < Date
0
+class DateTime < Date # :nodoc:
0
   def to_liquid
0
     self
0
   end
0
 end
0
 
0
-class Date
0
+class Date # :nodoc:
0
   def to_liquid
0
     self
0
   end
0
 end
0
 
0
-def true.to_liquid
0
+def true.to_liquid # :nodoc:
0
   self
0
 end
0
 
0
-def false.to_liquid
0
+def false.to_liquid # :nodoc:
0
   self
0
 end
0
 
0
-def nil.to_liquid
0
+def nil.to_liquid # :nodoc:
0
   self
0
 end
0
\ No newline at end of file
...
14
15
16
17
 
18
19
20
...
14
15
16
 
17
18
19
20
0
@@ -14,7 +14,7 @@ module Liquid
0
     def name
0
       self.class.name.downcase
0
     end
0
-
0
+
0
     def render(context)
0
       ''
0
     end
...
1
2
3
 
4
5
6
...
12
13
14
15
16
 
 
17
18
19
...
1
2
 
3
4
5
6
...
12
13
14
 
 
15
16
17
18
19
0
@@ -1,6 +1,6 @@
0
 module Liquid
0
   class Assign < Tag
0
- Syntax = /(\w+)\s*=\s*(#{QuotedFragment}+)/
0
+ Syntax = /(#{VariableSignature}+)\s*=\s*(#{QuotedFragment}+)/
0
   
0
     def initialize(markup, tokens)
0
       if markup =~ Syntax
0
@@ -12,8 +12,8 @@ module Liquid
0
     end
0
   
0
     def render(context)
0
- context[@to] = context[@from]
0
- ''
0
+ context.scopes.last[@to.to_s] = context[@from]
0
+ ''
0
     end
0
   
0
   end
...
11
12
13
14
15
16
 
17
18
19
20
21
22
 
 
 
 
 
 
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
 
 
 
43
44
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
47
48
49
50
51
52
53
54
55
56
57
 
 
 
 
58
59
60
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
63
64
...
11
12
13
 
 
 
14
15
16
17
18
 
 
19
20
21
22
23
24
25
26
27
28
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
31
32
33
 
 
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
 
 
 
 
 
 
 
 
53
54
55
56
57
 
 
 
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
0
@@ -11,54 +11,65 @@ module Liquid
0
       else
0
         raise SyntaxError.new("Syntax Error in tag 'case' - Valid syntax: case [condition]")
0
       end
0
-
0
- push_block('case', markup)
0
-
0
+
0
       super
0
     end
0
 
0
     def unknown_tag(tag, markup, tokens)
0
- if ['when', 'else'].include?(tag)
0
- push_block(tag, markup)
0
+ @nodelist = []
0
+ case tag
0
+ when 'when'
0
+ record_when_condition(markup)
0
+ when 'else'
0
+ record_else_condition(markup)
0
       else
0
         super
0
       end
0
     end
0
 
0
- def render(context)
0
- @blocks.inject([]) do |output, block|
0
-
0
- if block.else?
0
- return render_all(block.attachment, context) if output.empty? || output.join !~ /\S/
0
- else
0
-
0
- if block.evaluate(context)
0
- context.stack do
0
- output += render_all(block.attachment, context)
0
- end
0
- end
0
-
0
- end
0
-