2012-06-06 9 views
6

Próbuję wyjściowego coś wzdłuż liniiInline haml Linki ale z zawartością

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

ale stosując haml

Jak to zrobić? Ciągle znajduję przykłady, ale żaden nie pokazuje, jak to zrobić, ale zwykłym tekstem po obu stronach łącza?

Neil

Odpowiedz

20

Jeśli chcesz zrobić 1 wykładziny:

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

Multiline

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

prostu próbowałem to: % p = "To jest mój tekst # {link_to "Zobacz wszystkie albumy", albums_path}" Ale to właśnie wyprowadza To jest mój tekst See ALL albums jak bym rozwiązać to? – rctneil

+0

dodaj html_safe do końca (zmieniono w odpowiedzi) –

+0

% p = "To jest mój tekst # {link_to" Zobacz WSZYSTKIE albumy ", albums_path}". Html_safe –

2

Trzeba po prostu być w stanie to zrobić:

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

to będzie działać zbyt:

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