class Jbuilder
def child!
json.content comment.formatted_content
json.comments(@post.comments) do |comment|
More commonly, you'd use the combined iterator, though:
{ "comments": [ { "content": "hello" }, { "content": "world" } ]}
end
json.child! { json.content "world" }
json.child! { json.content "hello" }
json.comments do
Example:
Turns the current element into an array and yields a builder to add a hash.
def child! @attributes = [] unless ::Array === @attributes @attributes << _scope{ yield self } end