【问题标题】:rails 3.1, partial, using haml?rails 3.1,部分,使用haml?
【发布时间】:2011-11-04 06:58:20
【问题描述】:

我正在尝试部分使用haml,我写道:

%p.nested-check-fields
    = f.input :is_correct
    = link_to_remove_fields "remove choice", f

但是,在生成的 HTML 中,我得到了

<p class="nested-check-fields"> </p>
<div class="input boolean optional">
<input type="hidden" value="0" name="quiz[quiz_choices_attributes][1320389712363][is_correct]">
<input id="quiz_quiz_choices_attributes_1320389712363_is_correct" class="boolean optional" type="checkbox" value="1" name="quiz[quiz_choices_attributes][1320389712363][is_correct]">
<label class="boolean optional" for="quiz_quiz_choices_attributes_1320389712363_is_correct"> Is correct</label>
</div>

问题是,为什么&lt;p class="nested-check-fields"&gt; &lt;/p&gt; 是空的?我期待将 div 包裹在其中,怎么了??

【问题讨论】:

  • 不是惯例吗:缩进两个空格?

标签: ruby-on-rails-3 haml


【解决方案1】:

Haml 对缩进非常严格(来自documentation):

Haml 的缩进可以由一个或多个制表符或空格组成。 但是,缩进必须在给定文档中保持一致。难的 制表符和空格不能混用,相同数量的制表符或空格 必须始终使用。

听起来您实际上可以使用 4 个空格而不是 2 个,但这意味着您必须在任何地方使用 4 个空格(不能混合使用)。我建议只使用 2 个空格缩进,因为这是最常见的。

【讨论】:

    猜你喜欢
    • 2011-12-21
    • 1970-01-01
    • 2018-07-13
    • 2012-08-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-02
    • 1970-01-01
    相关资源
    最近更新 更多