【发布时间】:2011-09-01 09:20:04
【问题描述】:
在 HAML 中,我经常想在标签之后使用标点符号。例如,我可能想把一些东西加粗,但有一个右括号。格式如下所示:(带有粗体文本的例句。)
请注意,“粗体文本”是粗体,但句号和右括号“.)”不是。
明显的HAML是这样的:
(Example sentence with
%span.important bold text
\.)
但这会导致“粗体文本”和“.)”之间出现额外的空格。这是一种替代方法:
(Example sentence with
%span.important bold text
%span>\.)
用> 将'.)' 括在跨度中会使空格消失。但是,这需要不必要的跨度。
有没有什么方法可以在没有额外跨度的情况下获得所需的输出?
【问题讨论】:
-
haml 常见问题解答几乎涵盖了这个确切的问题:haml-lang.com/docs/yardoc/file.FAQ.html#q-punctuation - 答案与下面的 Daves 基本相同:内联 html 或过滤器。
-
感谢@Dave,我已经调整了示例以使其更清晰。
-
chriseppstein.github.com/blog/2010/02/08/haml-sucks-for-content 这可能会对您有所帮助 :) 它只支持 matt 和 Dave 的断言,即您可以将 inline/markdown 用于内联标签..因为 haml 用于布局
-
有 3 个 HAML 助手(surround、preced 和succeed)专门解决了这个问题。阅读Haml: Control whitespace around text 或阅读HAML documentation 中的“Helper Methods”
标签: haml