简体   繁体   中英

Passing locals from partial view to another partial view

I want pass all passed locals from one partial view to 0-N inner partial views.

Example:

# my_view.html.erb
<%= render partial: 'my_partial_view', locals: { ...dynamic amount of variables... } %>
...
# _my_partial_view.html.erb
<%= render partial: 'inner_partial_view_A', locals: ??? if ABC %>
<%= render partial: 'inner_partial_view_B', locals: ??? if DEF %>
<%= render partial: 'inner_partial_view_C', locals: ??? if XYZ %>

Try following

<%= render partial: 'inner_partial_view_A', local_assigns if ABC %>
<%= render partial: 'inner_partial_view_B', local_assigns if DEF %>
<%= render partial: 'inner_partial_view_C', local_assigns if XYZ %>

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM