如何使用纤薄的模板语言在段落中间放置超链接?

Eri*_*rik 14 ruby templates slim-lang

你如何用苗条的模板语言写下以下内容?

<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>
Run Code Online (Sandbox Code Playgroud)

我尝试了以下方法:

p
  ' Join the
  a href="" Google Group
  ' and let us know what you think, or what other features you’d like to see
Run Code Online (Sandbox Code Playgroud)

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

Eri*_*rik 20

显然你可以在报价后添加额外的空格:

p
  ' Join the
  a href="" Google Group
  '  and let us know what you think, or what other features you’d like to see
Run Code Online (Sandbox Code Playgroud)

  • 这种语法让我想呕吐一点. (9认同)

wha*_*ohn 8

你可以做

 p This is a paragraph with a link #{link_to 'embedded', 'http://google.com'}.
Run Code Online (Sandbox Code Playgroud)

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