You could use a partial.
foo.html.haml
- if i_should_link
%a{:href => url}
= render 'bar'
- else
= render 'bar'
_bar.html.haml
.foo
.block
.of
.code
Edit: Or you could use content for, I guess this is better because it keeps it all in the same file.
- if i_should_link
%a{:href => url}
= yield :foobar
- else
= yield :foobar
- content_for :foobar do
.foo
.block
.of
.code
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…