Haml: Control whitespace around text

前端 未结 13 2162
时光说笑
时光说笑 2020-11-30 16:38

In my Rails template, I\'d like to accomplish final HTML to this effect using HAML:

I will first link somewhere         


        
13条回答
  •  难免孤独
    2020-11-30 17:29

    Although not well documented, this is cleanly achieved using HAML whitespace preservation (>) combined with an ASCII space (& #32;), and not with helpers:

    %a{:href=>'/home'}> Home link
    ,  
    %a{:href=>'/page'} Next link
    

    This will produce what you want:

    Anchor text, 
    More text
    

    But I agree, HAML needs to come up with a better way of doing this, as it does add unnecessary ASCII characters to the page (but it's still more efficient than using helpers).

提交回复
热议问题