rails 3.1,部分,使用haml? [英] rails 3.1, partial, using haml?

查看:65
本文介绍了rails 3.1,部分,使用haml?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图部分使用haml,我写道:

I am trying to use haml in a partial, I wrote:

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

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

but, in the resulted HTML, I get

<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>

问题是,为什么<p class="nested-check-fields"> </p>为空?我原本希望将div包裹在里面,怎么了?

The question is, why the <p class="nested-check-fields"> </p> is empty ?? I was expecting to wrap the div inside it, what's wrong ??

推荐答案

Haml对于缩进非常严格(来自

Haml is very strict about indentation (from the documentation):

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

Haml’s indentation can be made up of one or more tabs or spaces. However, indentation must be consistent within a given document. Hard tabs and spaces can’t be mixed, and the same number of tabs or spaces must be used throughout.

听起来您实际上可以使用4个空格而不是2个空格,但这意味着您到处都必须使用4个空格(不能混合使用).我建议只坚持使用2空格缩进,因为这是最常见的.

It sounds like you can actually use 4 spaces instead of 2, but that means you have to use 4 spaces everywhere (you can't mix it). I'd recommend just sticking with 2-space indentation, as that's the most common.

这篇关于rails 3.1,部分,使用haml?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆