Node.js,Jade Escape标记 [英] nodejs, jade escape markup
本文介绍了Node.js,Jade Escape标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个使用默认Jade视图引擎的Express应用程序.当我尝试在< pre>
元素中按原样呈现HTML时,它将被呈现为实际的DOM元素,而不是文字字符.
I have an Express app using the default Jade view engine. When I try to render HTML as-is in a <pre>
element, it gets rendered as actual DOM elements instead of literal characters.
h1 Code Sample
pre
code
<div>some text</div>
输出:
<h1>Code Sample</h1>
<pre>
<code>
<div>some text</div>
</code>
</pre>
如何转义HTML,以使其呈现如下?
How do I escape the HTML so that it gets rendered as follows?
<h1>Code Sample</h1>
<pre>
<code>
<div>some text</div>
</code>
</pre>
推荐答案
Jade使用bang强制输出未转义的输出.因此,您可以使用以下结构将常规输出转换为未转义的输出:!=
如果您的内容在div标签内,则可以执行以下操作:
Jade uses the bang to force unescaped output. So you turn regular output to unescaped output with the following construct: !=
If your content is inside an div tag you could do the following:
div!= content
这篇关于Node.js,Jade Escape标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文