【问题标题】:Why use 'succeed do' in haml?为什么在haml中使用'succeed do'?
【发布时间】:2013-04-30 02:21:12
【问题描述】:

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

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

succeed 调用似乎没有必要。这只是从html到haml转换的一个神器吗?

【问题讨论】:

    标签: haml


    【解决方案1】:

    如果你尝试

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

    并且空白在行内元素中很重要 - 请参阅我在this question中的(迟到的)答案

    【讨论】:

    • 好点!我还意识到,如果您想格式化单词的一部分,例如&lt;b&gt;piece&lt;/b&gt;meal,那么调用succeed 将防止“piece”和“meal”之间出现空格
    猜你喜欢
    • 2014-07-16
    • 2022-07-27
    • 2012-03-18
    • 2016-10-25
    • 2011-07-08
    • 2018-10-10
    • 1970-01-01
    • 2020-11-02
    • 2017-03-31
    相关资源
    最近更新 更多