【发布时间】:2014-09-25 19:24:59
【问题描述】:
最近在我们的项目中,我们尝试将大部分视图文件从 ERB 迁移到 HAML。 今天偶然发现一个问题,我想不通。
我有这样的文件结构
-- _header.html.haml
-- index.html.haml
-- show.html.haml
在我们的头文件中,我们打开一些标签,例如:
_header.html.haml
%section.page
.wrapper
但是在 index 和 show 文件中,我们将这个 header 部分渲染成这样
index.html.haml
= render "layouts/structure/faq_header"
%section.noborder{ id: "fp-1" }
%h2{id: "c1"}= @question_group.title
当 HAML 被编译为 html 时,所有标签最后都在 _header.html.haml 文件中关闭,但我需要它们仅在父文件中关闭,是否有可能,如果没有,是否有任何解决方法所以最终结果如下所示:
<section class="page">
<div class="wrapper">
<section class="noborder" id="fp-1">
<h2 id="c1">
<%= @question_group.title %>
</h2>
</section>
</div>
</section>
不是这样的:
<section class="page">
<div class="wrapper">
</div>
</section>
<section class="noborder" id="fp-1">
<h2 id="c1">
<%= @question_group.title %>
</h2>
</section>
【问题讨论】:
标签: ruby-on-rails ruby haml