I have this partial that renders a line containing three peaces of data contained in a span, and between the spans there is a hyphen. Since the hyphen is a haml keyword (or whatever you call that) you can't just put it between the spans, or haml would go looking for a function or variable. So I've got this
%p
%span{ :class => 'client'}= "#{ won_or_lost['object']['deal']['client'] }"
= "-"
%span{ :class => 'value'}= "#{ won_or_lost['object']['deal']['value'] }"
= "- Thanks to"
%span{ :class => 'owner'}= "#{ won_or_lost['object']['deal']['owner'] }
You probably agree with me that
= "-"
is rather ugly. It's not a real problem, but is there a clean way to do this?
%p
%span.client= won_or_lost['object']['deal']['client']
\-
%span.value= won_or_lost['object']['deal']['value']
\- Thanks to
%span.owner= won_or_lost['object']['deal']['owner']
http://haml-lang.com/docs/yardoc/file.HAML_REFERENCE.html#escaping_
I sometimes prefer to use an Em-dash, which I think looks better typographically:
%p
%span.client= won_or_lost['object']['deal']['client']
—
%span.value= won_or_lost['object']['deal']['value']
— Thanks to
%span.owner= won_or_lost['object']['deal']['owner']
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