Haml: Control whitespace around text

前端 未结 13 2176
时光说笑
时光说笑 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:15

    I came across a similar problem and found this so I thought I would post another solution which doesn't require a helper method. Use Ruby interpolation #{} to wrap the link and if statements:

    I will first 
    #{link_to 'link somewhere', 'http://example.com'}#{if true : ", then render this half of the sentence if a condition is met" end}
    

    This works in 3.0.18, it may also work in earlier releases.

提交回复
热议问题