【发布时间】:2015-03-09 10:06:03
【问题描述】:
在“show.html.haml”中,我有两个这样的渲染:
= render 'project_header', :locals => {@set_tab => "current"}
= render 'project_toolbar'
我的“_project_header.html.haml”看起来像:
%article.project
%header
%h1.generated
#some_code
%h2
#some_code
我的“_project_toolbar.html.haml”看起来像:
%section.toolbar
#some_code
这最终出现在 html 中,类似于:
<article class="project">
#some_code
</article>
<section class="toolbar">
#some_code
</section>
我想要的是代替
<article class="project">
#some_code
<section class="toolbar">
#some_code
</section>
</article>
我知道可以解决一些问题,比如在“project_header”中渲染我的“project_toolbar”。但它们是两个逻辑上独立的实体,所以我不想那样做。 有什么建议吗?
【问题讨论】:
-
除了在
project_header中渲染project_toolbar之外,我看不到任何其他方式。 -
你知道另一种方式可能是剥离“文章”,而写作就在两者呈现之前。不过,如果它是 erb,它本来是可能的.. 不是 haml 比 erb 更好吗?
标签: html ruby-on-rails ruby-on-rails-4 haml renderpartial