How to get all locals as a hash in a partial view.
如何在局部视图中将所有本地作为哈希。
# mainview.html.haml:
= render 'v1', p1: 100, p2: 'some_value', _other_values_
in a partial view:
在局部视图中:
# _v1.html.haml
# do something here...
# render another partial view
= render 'another_view', locals: locals # what to write here???
How to access ALL variables in locals as a hash. I don't want to list all variables in locals.
如何访问本地中的所有变量作为哈希。我不想在本地列出所有变量。
1 个解决方案
#1
Use local_assigns
.
local_assigns #=> { p1: 100, p2: 'some_value', _other_values_ }
_v1.html.haml
= render 'another_view', local_assigns
#1
Use local_assigns
.
local_assigns #=> { p1: 100, p2: 'some_value', _other_values_ }
_v1.html.haml
= render 'another_view', local_assigns