Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HAML: remove white space after "link_to"

The following code leaves a white space in HTML:

= link_to "Login", "#" 

Normally, HAML allows to remove it by putting ">" at the end of the line, for example:

%input#query{:type => "text", :value => "Search"}> 

However, that seems to be impossible, when Rails code is inserted.

How do I fix this?

like image 683
krn Avatar asked Apr 15 '11 17:04

krn


1 Answers

The solution with span is not ideal as it adds an unnecessary html tag that will require processing, if you want to avoid the <span> you should use HAML's succeed:

= succeed "," do   = link_to "Login", "#" 

which will result in the following HTML being rendered:

Login, 

rather than

Login , 

Note that if you want to achieve the following result:

Login,Profile 

i.e. no whitespace whatsoever between the comma and two links you should do the following:

= succeed link_to "Profile", '#' do   = succeed "," do     = link_to "Login", '#' 

which gets pretty tedious

like image 139
Georgi Avatar answered Sep 22 '22 12:09

Georgi