A better way to do this has been introduced via Haml’s helpers:
surround
= surround '(', ')' do
%a{:href => "https://stackoverflow.com/questions/1311428/food"} chicken
Produces:
(<a href="https://stackoverflow.com/questions/1311428/food">chicken</a>)
succeed:
click
= succeed '.' do
%a{:href=>"https://stackoverflow.com/questions/1311428/thing"} here
Produces:
click
<a href="https://stackoverflow.com/questions/1311428/thing">here</a>.
precede:
= precede '*' do
%span.small Not really
Produces:
*<span class="small">Not really</span>
To answer the original question:
I will first
= succeed ',' do
= link_to 'link somewhere', 'http://example.com'
- if @condition
then render this half of the sentence if a condition is met
Produces:
I will first
<a href="http://example.com">link somewhere</a>,
then render this half of the sentence if a condition is met