打印变量没有在Pug中包装标签
我想在标签内打印一些任意内容。内容应通过Javascript设置。这是一个最小的示例:
pugpileFile("templates/question.pug")({
headExtraContent: "<script>console.log('hello')</script>",
});
doctype
head
title Some page title
// headExtraContent should go here in an unescaped form
body
...
我尝试过#{headExtraContent}
,={headExtraContent
,但没有一个起作用。
在Pug中有没有办法实现这一目标?
回答如下:[Pug.js docs,!{headExtraContent}
将插入内容而不会转义。