Add root in DSL
This commit is contained in:
parent
9f0a92ecd7
commit
a97a8cd24f
@ -1,6 +1,7 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 0.2.0 (unrelased)
|
||||
* Add `root` in DSL to set root without changing the source
|
||||
* Add XML renderer
|
||||
* Use MultiJson's preferred JSON engine as default (shmeltex)
|
||||
* Default template to render with responder can be set per controller
|
||||
|
@ -30,6 +30,10 @@ module RablRails
|
||||
end
|
||||
alias_method :collection, :object
|
||||
|
||||
def root(name)
|
||||
@template.root_name = name
|
||||
end
|
||||
|
||||
#
|
||||
# Includes the attribute or method in the output
|
||||
# Example:
|
||||
|
@ -24,6 +24,16 @@ class CompilerTest < ActiveSupport::TestCase
|
||||
assert_equal({}, t.source)
|
||||
end
|
||||
|
||||
test "root can be defined via keyword" do
|
||||
t = @compiler.compile_source(%{ root :author })
|
||||
assert_equal :author, t.root_name
|
||||
end
|
||||
|
||||
test "root keyword override object root" do
|
||||
t = @compiler.compile_source(%{ object :@user ; root :author })
|
||||
assert_equal :author, t.root_name
|
||||
end
|
||||
|
||||
test "collection set the data for the template" do
|
||||
t = @compiler.compile_source(%{ collection :@user })
|
||||
assert_equal :@user, t.data
|
||||
|
Loading…
Reference in New Issue
Block a user