Allow to set root_name to false in template

This commit is contained in:
ccocchi 2012-07-20 15:14:46 +02:00
parent cfd9e3e65d
commit b61fdec326
2 changed files with 7 additions and 2 deletions

View File

@ -26,7 +26,7 @@ module RablRails
#
def object(data, options = {})
@template.data, @template.root_name = extract_data_and_name(data)
@template.root_name = options[:root] if options[:root]
@template.root_name = options[:root] if options.has_key? :root
end
alias_method :collection, :object
@ -60,7 +60,7 @@ module RablRails
#
def child(name_or_data, options = {})
data, name = extract_data_and_name(name_or_data)
name = options[:root] if options[:root]
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)

View File

@ -42,6 +42,11 @@ class CompilerTest < ActiveSupport::TestCase
assert_equal :@user, t.data
assert_equal :users, t.root_name
end
test "root can be set to false via options" do
t = @compiler.compile_source(%( object :@user, root: false))
assert_equal false, t.root_name
end
# Compilation