最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

打印变量没有在Pug中包装标签

运维笔记admin12浏览0评论

打印变量没有在Pug中包装标签

打印变量没有在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}将插入内容而不会转义。

发布评论

评论列表(0)

  1. 暂无评论