【问题标题】:How to put a hyperlink in the middle of a paragraph using the slim templating language?如何使用苗条的模板语言在段落中间放置超链接?
【发布时间】:2011-09-27 11:15:15
【问题描述】:

您如何用slim 模板语言编写以下内容?

<p>Join the <a href="">Google group</a> and let us know what you think, or what other features you’d like to see.</p>

我尝试了以下方法:

p
  ' Join the
  a href="" Google Group
  ' and let us know what you think, or what other features you’d like to see

但这不起作用,因为“Group”和“and”这两个词之间没有空格。

【问题讨论】:

    标签: ruby templates slim-lang


    【解决方案1】:

    显然你可以在引号后添加额外的空格:

    p
      ' Join the
      a href="" Google Group
      '  and let us know what you think, or what other features you’d like to see
    

    【讨论】:

    • 这是正确的。引号后的空格成为您的左边距。您可以在行首添加任意数量的空格。
    • 这个语法让我有点想吐。
    • 哇,我们来看看另一个答案。
    • 但这并不能在“the”和“Google”之间找到一个空格。我还是想不通。
    【解决方案2】:

    你可以的

     p This is a paragraph with a link #{link_to 'embedded', 'http://google.com'}.
    

    Rails 标签助手只是方法,因此您可以将该逻辑应用于视图中的其他方法。

    【讨论】:

      猜你喜欢
      • 2011-04-08
      • 1970-01-01
      • 2020-05-01
      • 2012-04-30
      • 2012-04-20
      • 1970-01-01
      • 2015-06-29
      • 1970-01-01
      • 2014-02-16
      相关资源
      最近更新 更多