cutaneous 0.1.2 → 0.1.3
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.
- data/cutaneous.gemspec +3 -1
- data/lib/cutaneous/context.rb +7 -1
- data/lib/cutaneous.rb +1 -1
- data/test/fixtures/locals/child.html.cut +1 -0
- data/test/fixtures/locals/parent.html.cut +3 -0
- data/test/test_core.rb +6 -0
- metadata +3 -1
data/cutaneous.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
## If your rubyforge_project name is different, then edit it and comment out
|
15
15
|
## the sub! line in the Rakefile
|
16
16
|
s.name = 'cutaneous'
|
17
|
-
s.version = '0.1.
|
17
|
+
s.version = '0.1.3'
|
18
18
|
s.date = '2012-07-25'
|
19
19
|
s.rubyforge_project = 'cutaneous'
|
20
20
|
|
@@ -86,6 +86,8 @@ Gem::Specification.new do |s|
|
|
86
86
|
test/fixtures/included_error.html.cut
|
87
87
|
test/fixtures/instance.html.cut
|
88
88
|
test/fixtures/instance_include.html.cut
|
89
|
+
test/fixtures/locals/child.html.cut
|
90
|
+
test/fixtures/locals/parent.html.cut
|
89
91
|
test/fixtures/missing.html.cut
|
90
92
|
test/fixtures/other/different.html.cut
|
91
93
|
test/fixtures/other/error.html.cut
|
data/lib/cutaneous/context.rb
CHANGED
@@ -20,10 +20,16 @@ module Cutaneous
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def include(template_name, locals = {})
|
23
|
-
context = self.
|
23
|
+
context = self.clone(locals)
|
24
24
|
self.__buf << __loader.template(template_name).render(context)
|
25
25
|
end
|
26
26
|
|
27
|
+
def clone(locals = {})
|
28
|
+
context = self.class.new(__target, self)
|
29
|
+
context.__update_with_locals(locals)
|
30
|
+
context
|
31
|
+
end
|
32
|
+
|
27
33
|
def respond_to_missing?(name, include_private = false)
|
28
34
|
return true if @__locals.key?(name.to_s) || @__locals.key?(name.to_sym)
|
29
35
|
super
|
data/lib/cutaneous.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
${ title }
|
data/test/test_core.rb
CHANGED
@@ -215,4 +215,10 @@ describe Cutaneous do
|
|
215
215
|
result = engine.render_string("${ monkey } ${ to_s }", context)
|
216
216
|
result.must_equal "magic fairy"
|
217
217
|
end
|
218
|
+
|
219
|
+
it "Preserves the original context locals after includes" do
|
220
|
+
context = ContextHash({})
|
221
|
+
result = engine.render("locals/parent", context)
|
222
|
+
result.must_equal "Child 1\nChild 2\n\n"
|
223
|
+
end
|
218
224
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cutaneous
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -50,6 +50,8 @@ files:
|
|
50
50
|
- test/fixtures/included_error.html.cut
|
51
51
|
- test/fixtures/instance.html.cut
|
52
52
|
- test/fixtures/instance_include.html.cut
|
53
|
+
- test/fixtures/locals/child.html.cut
|
54
|
+
- test/fixtures/locals/parent.html.cut
|
53
55
|
- test/fixtures/missing.html.cut
|
54
56
|
- test/fixtures/other/different.html.cut
|
55
57
|
- test/fixtures/other/error.html.cut
|