ccocchi / rabl-rails

Rails 4.2+ templating system with JSON, XML and Plist support.
MIT License
209 stars 51 forks source link

You can't render anonymous child nodes #22

Closed paos closed 11 years ago

paos commented 11 years ago

The original rabl gem allows the option

config.include_child_root = false

This is not possible with rabl-rails. Also you can render an anonymous node in the original rabl with

node do |obj|
      { some_att: obj.some_val }
end

This is also not possible with rabl-rails as node have a mandatory node-name argument If you supply nil as an argument to node, the node root will just be an empty string.

Is there any way to work around this?

ccocchi commented 11 years ago

The include_child_root is not present in rabl-rails because it behaves already without child root nodes. I think it is a bad design to return something like this:

{ users: [ user: {}, user:] }

Rendering anonymous node issue is a duplicate of #13. This will be available in the next release of this gem.