What i have: Several references to the same partial
but with different locals
like
<%= render :partial => 'link/to/partial', :locals => {:fieldtype => 'textline', :text => object.text} %>
<%= render :partial => 'link/to/partial', :locals => {:fieldtype => 'list', :list => object.list, :header => 'HEADER'} %>
Now _partial.html.erb
has the following line:
<%= render :partial => 'link/to/partial/'+fieldtype, :locals => locals %>
What i want: Obviously :locals => locals
does not work. How can i link all the locals to the next partial?
Just for clarification, you could put all the locals in a hash like this:
<% my_locals = {:fieldtype => 'textline', :text => object.text} %>
<%= render :partial => 'link/to/partial', :locals => {:my_locals => my_locals} %>
(Not that it can be confusing that {}
are both used for declaring a hash and a block)
In your partial you would then do this:
<%= render :partial => 'link/to/partial/'+my_locals[:fieldtype], :locals => {:my_locals => my_locals} %>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.