我有这个部分呈现包含跨度中包含三个和平数据的行,并且在跨度之间有一个连字符。因为连字符是haml关键字(或者你称之为的任何关键字),所以你不能将它放在跨度之间,否则haml会寻找函数或变量。所以我有了这个
%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'] }
你可能同意我的意见
=“ - ”
相当难看。这不是一个真正的问题,但有一种干净的方法吗?
答案 0 :(得分:27)
%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_
答案 1 :(得分:14)
我有时更喜欢使用Em-dash,我觉得它的印刷效果更好:
%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']