为什么在Haml中要使用“succeed do”?

18

我使用了html2haml.heroku.com,它将一些普通的字符串转换成了以下内容:

A normal sentence is here
= succeed '.' do
  %strong and it is cut off randomly by this succeed

succeed调用看起来是不必要的。这只是从html转换为haml的产物吗?

1个回答

28

如果你尝试过

A normal sentence is here
= succeed '.' do
  %strong and it is cut off randomly by this succeed

如果生成HTML,输出将会像这样:

A normal sentence is here
<strong>and it is cut off randomly by this succeed</strong>.

然而,如果您尝试类似以下的操作

A normal sentence is here
%strong and it is cut off randomly by this succeed
.

您将会拥有这样的输出结果:

A normal sentence is here
<strong>and it is cut off randomly by this succeed</strong>
.

而且,在内联元素中,空格很重要 - 请参考我在这个问题中的(晚了一点)回答。


好观点!我也意识到,如果您想格式化单词的一部分,例如<b>piece</b>meal,那么调用succeed将防止“piece”和“meal”之间有空格。 - Clucking Turtle

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接