内联HAML链接,但内容

时间:2012-06-06 21:12:08

标签: ruby-on-rails views haml

我正在尝试按照

的顺序输出内容
<p>Hello, this is my text. <a href="#">Link here</a> This is more text</p>

但使用HAML

如何做到这一点?我一直在找例子,但没有一个显示如何做,但在链接的任一侧都有明文?

尼尔

2 个答案:

答案 0 :(得分:25)

如果你想做一个班轮:

%p= "Hello, this is my text. #{link_to 'Link here', '#'} This is more text".html_safe

%p 
  Hello, this is my text. 
  = link_to 'Link here', '#'
  This is more text

答案 1 :(得分:2)

你应该能够做到这一点:

%p Hello, this is my text. <a href="#">Link here</a> This is more text

这也可行:

%p
  Hello, this is my test.
  %a{:href => '#'} Link here
  This is more text