roger 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/roger/template.rb +12 -4
- data/roger.gemspec +1 -1
- data/test/unit/template_test.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0e25d53fb264823bbd277555be283be84210460
|
4
|
+
data.tar.gz: a4618896d76651eb6002865640d2e5aa18b9442e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e4c474bbe2fe95edf3aed26bcf060810764ea55c8e639ea009e27878740479c05f22e69a8c3d76e37afc9680177a597fb10ff1c2743910f9cc52f2851bf6423
|
7
|
+
data.tar.gz: 50131d49a34dd8b8bb7fa9568066975469c3c6b4d877d3670d68196e60bdc937a741a973e07e2fd9239b5a75bde589eb338e7f0ac82e5cfc27e7d3c2a4e7736d
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## Version 1.1.2
|
4
|
+
|
5
|
+
* Fix issue where nested `content_for` statements or partials with blocks within a `content_for` block would yield multiple times.
|
6
|
+
|
3
7
|
## Version 1.1.1
|
4
8
|
|
5
9
|
* Better compatiblity with the release as `build` is a relative path it will give sometimes weird issues. This has now been resolved.
|
data/lib/roger/template.rb
CHANGED
@@ -35,6 +35,7 @@ module Roger
|
|
35
35
|
# @option options [String,Pathname] :partials_path The path to where all partials reside
|
36
36
|
def initialize(source, options = {})
|
37
37
|
@options = options
|
38
|
+
|
38
39
|
self.source_path = options[:source_path]
|
39
40
|
self.data, self.source = extract_front_matter(source)
|
40
41
|
self.template = Tilt.new(self.source_path.to_s){ self.source }
|
@@ -149,6 +150,9 @@ module Roger
|
|
149
150
|
def initialize(template, env={})
|
150
151
|
@_content_for_blocks = {}
|
151
152
|
@_template, @_env = template, env
|
153
|
+
|
154
|
+
# Block counter to make sure erbtemp binding is always unique
|
155
|
+
@block_counter = 0
|
152
156
|
end
|
153
157
|
|
154
158
|
# The current Roger::Template in use
|
@@ -184,12 +188,16 @@ module Roger
|
|
184
188
|
|
185
189
|
def capture(&block)
|
186
190
|
raise ArgumentError, "content_for works only with ERB Templates" if !self.template.template.kind_of?(Tilt::ERBTemplate)
|
187
|
-
|
191
|
+
|
192
|
+
@block_counter += 1
|
193
|
+
counter = @block_counter
|
194
|
+
|
195
|
+
eval "@_erbout_tmp#{counter} = _erbout", block.binding
|
188
196
|
eval "_erbout = \"\"", block.binding
|
189
197
|
t = Tilt::ERBTemplate.new(){ "<%= yield %>" }
|
190
|
-
t.render(&block)
|
198
|
+
t.render(&block)
|
191
199
|
ensure
|
192
|
-
eval "_erbout = @_erbout_tmp", block.binding
|
200
|
+
eval "_erbout = @_erbout_tmp#{counter}", block.binding
|
193
201
|
end
|
194
202
|
|
195
203
|
def partial(name, options = {}, &block)
|
@@ -214,4 +222,4 @@ module Roger
|
|
214
222
|
|
215
223
|
end
|
216
224
|
|
217
|
-
end
|
225
|
+
end
|
data/roger.gemspec
CHANGED
data/test/unit/template_test.rb
CHANGED
@@ -135,6 +135,11 @@ module Roger
|
|
135
135
|
assert_equal template.render, "BA"
|
136
136
|
end
|
137
137
|
|
138
|
+
def test_content_for_yield_with_partial_with_block
|
139
|
+
template = Template.new("---\nlayout: \"yield\"\n---\nB<% content_for :one do %><% partial 'test/yield' do %>CONTENT<% end %><% end %>A", @config.update(:source_path => @base + "html/test.html.erb"))
|
140
|
+
assert_equal template.render, "BAB-CONTENT-A"
|
141
|
+
end
|
142
|
+
|
138
143
|
# Environment
|
139
144
|
|
140
145
|
def test_template_env
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Flurin Egger
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-
|
13
|
+
date: 2015-06-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: thor
|