I'm writing text in haml:
Blab bla for any questions contact us on [email protected].
so the haml looks like
%p
Blab bla for any questions contact us on
= mail_to '[email protected]'
.
note . is dot in ascii, I can also replace that line with = '.'
(render string dot)
but the rendered text looks like
Blab bla for any questions contact us on [email protected] .
difference is that whitespace before dot at the end
the solution I came up with and works is
%p
Blab bla for any questions contact us on
= mail_to('[email protected]') + '.'
it's just I'm looking for best practice :) thx
I'd use this:
%p
Blab bla for any questions contact us on #{mail_to('[email protected]')}.
Also see the Haml FAQ:
Expressing the structure of a document and expressing inline formatting are two very different problems. Haml is mostly designed for structure, so the best way to deal with formatting is to leave it to other languages that are designed for it.
In this case you don't need another language, just interpolate the function.
If you were to use the ==
notation, for the line with mail_to, you should be able to do what you want, likle this:
== #{mail_to '[email protected]'}.
The ==
notation performs interpolation for the entire line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With