ensure that child usage does not manipulate cached template
This commit is contained in:
parent
297f8a9145
commit
cb53352607
@ -67,7 +67,7 @@ module RablRails
|
|||||||
name = options[:root] if options.has_key? :root
|
name = options[:root] if options.has_key? :root
|
||||||
if options[:partial]
|
if options[:partial]
|
||||||
template = Library.instance.compile_template_from_path(options[:partial])
|
template = Library.instance.compile_template_from_path(options[:partial])
|
||||||
@template[name] = template.merge!(:_data => data)
|
@template[name] = template.merge(:_data => data)
|
||||||
elsif block_given?
|
elsif block_given?
|
||||||
@template[name] = sub_compile(data) { yield }
|
@template[name] = sub_compile(data) { yield }
|
||||||
end
|
end
|
||||||
|
@ -2,7 +2,7 @@ module RablRails
|
|||||||
class CompiledTemplate
|
class CompiledTemplate
|
||||||
attr_accessor :source, :data, :root_name
|
attr_accessor :source, :data, :root_name
|
||||||
|
|
||||||
delegate :[], :[]=, :merge!, :to => :source
|
delegate :[], :[]=, :merge!, :merge, :to => :source
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@source = {}
|
@source = {}
|
||||||
|
@ -113,6 +113,7 @@ class CompilerTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
t = @compiler.compile_source(%{child(:user, :partial => 'users/base') })
|
t = @compiler.compile_source(%{child(:user, :partial => 'users/base') })
|
||||||
assert_equal( {:user => { :_data => :user, :id => :id } }, t.source)
|
assert_equal( {:user => { :_data => :user, :id => :id } }, t.source)
|
||||||
|
assert_equal( {:id => :id}, mock_template.source)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "glue is compiled as a child but with anonymous name" do
|
test "glue is compiled as a child but with anonymous name" do
|
||||||
|
Loading…
Reference in New Issue
Block a user