我有一个 <a>
带有 <svg>
的标签在其中标记。
a(href='#') Link
svg
use(xlink:href="icons.svg#alert")
这输出为
<a href="#">Link
<svg>
<use xlink:href="icons.svg#alert"></use>
</svg>
</a>
我的问题是换行符 Jade 很好地格式化意味着链接在文本和 SVG 之间有一个带下划线的空格。我读过有关使用标记插值语法将标记放入 block 中的信息,但仍会为 <svg>
等 block 标记插入换行符。 .
我有什么选择可以删除这个带下划线的空间并将 SVG 放在 <a>
中?标签?看来我对 Jade 换行的方式没有太多控制权。它可能需要一个 CSS 解决方案?
最佳答案
只需在编译时将pretty
选项设置为false
即可。来自 Jade API documentation :
pretty
:boolean | string
Adds whitespace to the resulting html to make it easier for a human to read using' '
as indentation. If a string is specified, that will be used as indentation instead (e.g.'\t'
).
这将有效地缩小生成的 HTML。
关于html - 如何强制 Jade 不缩进 block 标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37260585/