Add root option for collection
This commit is contained in:
parent
0011b57f8f
commit
fbcbbd2328
|
@ -52,8 +52,8 @@ module RablFastJson
|
||||||
alias_method :code, :node
|
alias_method :code, :node
|
||||||
|
|
||||||
def collection(data, options = {})
|
def collection(data, options = {})
|
||||||
@template.root_name = options[:root] if root_given?(options)
|
|
||||||
object(data)
|
object(data)
|
||||||
|
@template.root_name = options[:root] if root_given?(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
def extends(path)
|
def extends(path)
|
||||||
|
|
|
@ -103,6 +103,12 @@ class CompilerTest < ActiveSupport::TestCase
|
||||||
assert_equal :users, t.root_name
|
assert_equal :users, t.root_name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "collection property can define root name via options" do
|
||||||
|
t = @compiler.compile_source(%{ collection :@user, :root => :users })
|
||||||
|
assert_equal :@user, t.data
|
||||||
|
assert_equal :users, t.root_name
|
||||||
|
end
|
||||||
|
|
||||||
test "extends use other template source as itself" do
|
test "extends use other template source as itself" do
|
||||||
template = mock('template', :source => { :id => :id })
|
template = mock('template', :source => { :id => :id })
|
||||||
RablFastJson::Library.reset_instance
|
RablFastJson::Library.reset_instance
|
||||||
|
|
Loading…
Reference in New Issue