You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the Stache::Mustache::Handler compile method only passes controller instance variables to the view context - however in many circumstances you want to have more control over the render method - ie. not use the standard rails automagic way..
I would like to see this added to the compile method so that the locals hash is supported:
local_assigns.each do |key, val|
variable_name = '@'.concat(key.to_s).to_s.to_sym
variables << variable_name
mustache.instance_variable_set(variable_name, val)
end
that would enable me to do something like this in the controller#action
render 'people/new', locals: { person: person }
and therefore not have to create an instance variable as person becomes an attr_reader etc..
I am happy to provide you with a pull request if you like - Thanks
Steve
The text was updated successfully, but these errors were encountered:
if Rails.version >= "3.1"
# get the locals from the view context, is there a better way?
locals = view_context.send(:view_renderer).send(:_partial_renderer).instance_variable_get("@Locals") || {}
locals.each do |name, val|
instance_variable_set("@#{name}", val)
self[name] = val
end
end
Currently the Stache::Mustache::Handler compile method only passes controller instance variables to the view context - however in many circumstances you want to have more control over the render method - ie. not use the standard rails automagic way..
I would like to see this added to the compile method so that the locals hash is supported:
that would enable me to do something like this in the controller#action
render 'people/new', locals: { person: person }
and therefore not have to create an instance variable as person becomes an attr_reader etc..
I am happy to provide you with a pull request if you like - Thanks
Steve
The text was updated successfully, but these errors were encountered: