1
#whitepanelMID
#groups_view_scroller
= render 'show' do
= render 'short_field', locals: {label: 'Name:', value: @group.name}
= render 'short_field', locals: {label: 'Description:', value: @group.description}
以下
一个HAML模板,谐音是_show.html.haml(注意使用产量的)
%table#vert_table.no_borders{ cellpadding: '0', cellspacing: '0'}
%tbody
%tr
%td{ cols: 2 } My table
= yield
和_short_field.html.haml
%tr
%th.vert_table_heads= label
%td= value
问题是收益率似乎没有工作。
什么是正确的使用方法block in render
in HAML?
更新
我找到了一个解决办法,我不喜欢。
在HAML模板捕获输出像
#whitepanelMID
#groups_view_scroller
- rows = capture_haml do
= render partial: 'short_field', locals: {field_label: 'Name:', value: @group.name}
= render partial: 'short_field', locals: {field_label: 'Site:', value: @group.site.description}
= render partial: 'show', locals:{ content: rows}
%br/
与修改的部分_show.html.haml与content
变量,而不是yield
%table#vert_table.no_borders{ cellpadding: '0', cellspacing: '0'}
%tbody
%tr
%td{ cols: 2 } My table
!= content
高兴听到一个更好的办法!
你可以试试看看这个http://stackoverflow.com/questions/2951105/rails-render-partial-with-block – vidaica
谢谢@vidaica,我用'=渲染布局:..'并且做招! – carlosayam