cutaneous 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
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.2'
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
@@ -20,10 +20,16 @@ module Cutaneous
20
20
  end
21
21
 
22
22
  def include(template_name, locals = {})
23
- context = self.dup.__update_with_locals(locals)
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
@@ -7,7 +7,7 @@ require 'cutaneous/lexer'
7
7
  require 'cutaneous/compiler'
8
8
 
9
9
  module Cutaneous
10
- VERSION = "0.1.2"
10
+ VERSION = "0.1.3"
11
11
 
12
12
  class CompilationError < Exception; end
13
13
 
@@ -0,0 +1 @@
1
+ ${ title }
@@ -0,0 +1,3 @@
1
+ %{ include "locals/child", title: "Child 1" -}
2
+ %{ include "locals/child", title: "Child 2" -}
3
+ ${ 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.2
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