结束haml评论 [英] ending haml comments

查看:141
本文介绍了结束haml评论的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是haml的新人,这让我很难过。我不喜欢删除代码,我可以评论它,但我不知道如何正确地结束在haml的评论。

I am new to haml and this is stumping me. I don't like to delete code where I can comment it out but I have no idea how to properly end a comment in haml.

以下是代码段:

.field
 = f.label :member_id
 %br/
 = f.text_field :member_id
.field
 = f.label :instrument_type
 %br/

我试图注释掉第一个字段,所以我使用:

I'm trying to comment out the first field so I used:

/
.field
 = f.label :member_id
 %br/
 = f.text_field :member_id
.field
 = f.label :instrument_type
 %br/

但是注释掉了第一个字段之后的所有内容。

but that commented out everything after the first field.

然后我尝试:

/
 .field
  = f.label :member_id
  %br/
  = f.text_field :member_id
.field
 = f.label :instrument_type
 %br/

但它不喜欢,或:

 -#.field
 -# = f.label :member_id
 -# %br/
 -# = f.text_field :member_id
.field
 = f.label :instrument_type
 %br/

我必须缺少一些东西。

I must be missing something. I looked all over but the examples never show code after the comment.

推荐答案

这是你的间距导致的问题,而不是你的方法。以下是注释HAML中这些行的正确方法:

It's your spacing that is causing the problem, not your method. Here is the proper way to comment out those lines in HAML:

您的第四个示例非常接近

 -#.field
 -# = f.label :member_id
 -# %br/
 -# = f.text_field :member_id
.field
 = f.label :instrument_type
 %br/

已正确注释

-#.field
-#  = f.label :member_id
-#  %br
-#  = f.text_field :member_id
.field
  = f.label :instrument_type
  %br

这是非常接近您在上一个示例发布的,异常:您的注释行以 - #之前的空格开头。开始处的空间打破HAML。我也注意到,你的源代码缩进一个空格,而不是两个。这也将打破HAML。 它必须是两个缩进空格。

This is awfully close to what you posted on your last example, with a notable exception: Your comment lines begin with a space preceding the -#. That space at the beginning will break HAML. I also noticed that your source code is indenting by one space instead of two. This will also break HAML. It must be two spaces of indentation.

您可以从%br 行中删除尾部斜杠。

P.S. You can remove the trailing slash from your %br lines.

这篇关于结束haml评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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