The problem is that | at the end of a line (separated by a space) is recognized as the syntax for extended line breaks. What if you want to get this character as output?
Example
Suppose you want to create a menu like
Section 1 | Section 2 | ...
Note: if this is exactly what you need, see concatenate link_to with pipe .
Shows the presence or absence of links, depending on a specific condition. In HAML / Ruby on Rails, it might look like it doesn't work
%div.menu -if condition1? #{link_to 'Section 1', section_1_path} | -if condition2? #{link_to 'Section 2', section_2_path} | -if condition3? ...
Work around
As a (somehow dirty) workaround, I changed the code:
%div.menu -if condition1? #{link_to 'Section 1', section_1_path} #{'|'} -if condition2? #{link_to 'Section 2', section_2_path} #{'|'} -if condition3? ...
source share