2012-06-06 25 views
6

我想輸出的東西沿着在線HAML聯繫,但與內容

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

線,但使用HAML

這將如何做呢?我繼續找到示例,但沒有一個顯示如何做,但鏈接的任何一側都是純文本?

尼爾

回答

20

如果你想要做一個1個襯墊:

%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 
+0

只是嘗試這樣做: %P = 「這是我的文字#{的link_to 」查看全部相冊「,albums_path}」 但這只是輸出 這是我的文字See ALL albums 我會怎樣解決這個? – rctneil

+0

將html_safe添加到最後(在答案中更改) –

+0

%p =「這是我的文本#{link_to」查看所有相冊「albums_path}」。html_safe –

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