ccocchi / rabl-rails

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

extends @variable #40

Closed abrisse closed 11 years ago

abrisse commented 11 years ago

How to extends a view using a variable?

In my controller I define @resource and @extended_view and would like to extend using @extended_view which equals for exemple 'v1/events/show'

object :resource

attributes :id, :name

extends @extended_view
ccocchi commented 11 years ago

You can use something like this

merge { |resource| partial(@extended_view, resource) }
abrisse commented 11 years ago

@ccocchi. Thanks the following code did the trick:

merge { |resource| partial(@extended_view, object: resource) }