ensure that child usage does not manipulate cached template

This commit is contained in:
John Bintz 2013-01-22 14:16:44 -05:00
parent 297f8a9145
commit cb53352607
5 changed files with 8 additions and 7 deletions

View File

@ -67,7 +67,7 @@ module RablRails
name = options[:root] if options.has_key? :root
if 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?
@template[name] = sub_compile(data) { yield }
end

View File

@ -2,7 +2,7 @@ module RablRails
class CompiledTemplate
attr_accessor :source, :data, :root_name
delegate :[], :[]=, :merge!, :to => :source
delegate :[], :[]=, :merge!, :merge, :to => :source
def initialize
@source = {}

View File

@ -113,6 +113,7 @@ class CompilerTest < ActiveSupport::TestCase
t = @compiler.compile_source(%{child(:user, :partial => 'users/base') })
assert_equal( {:user => { :_data => :user, :id => :id } }, t.source)
assert_equal( {:id => :id}, mock_template.source)
end
test "glue is compiled as a child but with anonymous name" do