locomotive_liquid 2.4.1 → 2.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,6 @@ module Liquid
6
6
 
7
7
  # Return the size of an array or of an string
8
8
  def size(input)
9
-
10
9
  input.respond_to?(:size) ? input.size : 0
11
10
  end
12
11
 
@@ -10,7 +10,7 @@ module Liquid
10
10
 
11
11
  def initialize(tag_name, markup, tokens, context)
12
12
  if markup =~ Syntax
13
- @template_name = $1.gsub('\'', '').strip
13
+ @template_name = $1.gsub(/["']/o, '').strip
14
14
  else
15
15
  raise SyntaxError.new("Error in tag 'extends' - Valid syntax: extends [template]")
16
16
  end
@@ -10,15 +10,17 @@ module Liquid
10
10
  Syntax = /(#{QuotedFragment}+)/
11
11
 
12
12
  attr_accessor :parent
13
- attr_reader :name
13
+ attr_reader :name
14
14
 
15
15
  def initialize(tag_name, markup, tokens, context)
16
16
  if markup =~ Syntax
17
- @name = $1
17
+ @name = $1.gsub(/["']/o, '').strip
18
18
  else
19
19
  raise SyntaxError.new("Error in tag 'block' - Valid syntax: block [name]")
20
20
  end
21
21
 
22
+ self.set_full_name!(context)
23
+
22
24
  (context[:block_stack] ||= []).push(self)
23
25
  context[:current_block] = self
24
26
 
@@ -56,6 +58,12 @@ module Liquid
56
58
 
57
59
  protected
58
60
 
61
+ def set_full_name!(context)
62
+ if context[:current_block]
63
+ @name = context[:current_block].name + '/' + @name
64
+ end
65
+ end
66
+
59
67
  def register_current_block
60
68
  @context[:blocks] ||= {}
61
69
 
@@ -132,6 +132,31 @@ module Liquid
132
132
  @rethrow_errors = true; render(*args)
133
133
  end
134
134
 
135
+ def walk(memo = {}, &block)
136
+ # puts @root.nodelist.inspect
137
+ self._walk(@root.nodelist, memo, &block)
138
+ end
139
+
140
+ def _walk(list, memo = {}, &block)
141
+ list.each do |node|
142
+ saved_memo = memo.clone
143
+
144
+ # puts "fetch ! #{node.respond_to?(:name) ? node.name : 'String'} / #{node.respond_to?(:nodelist)}"
145
+ if block_given?
146
+ # puts "youpi ! #{node.name}"
147
+ _memo = yield(node, memo) || {}
148
+ memo.merge!(_memo)
149
+ end
150
+
151
+ if node.respond_to?(:nodelist) && !node.nodelist.blank?
152
+ self._walk(node.nodelist, memo, &block)
153
+ end
154
+
155
+ memo = saved_memo
156
+ end
157
+ memo
158
+ end
159
+
135
160
  private
136
161
 
137
162
  # Uses the <tt>Liquid::TemplateParser</tt> regexp to tokenize the passed source
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: locomotive_liquid
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
5
4
  prerelease:
5
+ version: 2.4.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Tobias Luetke
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-11-20 00:00:00.000000000 Z
14
+ date: 2012-12-16 00:00:00.000000000 Z
15
15
  dependencies: []
16
16
  description: A secure, non-evaling end user template engine with aesthetic markup.
17
17
  Extended with liquid template inheritance for use in LocomotiveCMS
@@ -81,10 +81,10 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
81
  requirements:
82
82
  - - ! '>='
83
83
  - !ruby/object:Gem::Version
84
- version: '0'
85
84
  segments:
86
85
  - 0
87
- hash: -1636499300789474358
86
+ hash: -1080489168898257421
87
+ version: '0'
88
88
  required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  none: false
90
90
  requirements: