Rendering HTML in variable using Jade

∥☆過路亽.° 提交于 2019-11-27 04:19:51

问题


I have some text stored in a variable which contains some HTML. For example, the <b>cat</b> in the hat. However, when I render it in Jade, it shows up with the tags instead of rendering the formatting. How can I fix this?


回答1:


Code buffered by = is escaped by default for security, however to output unescaped return values you may use !=

p!= aVarContainingHTML

Pug Doc




回答2:


The syntax you need is :

!{yourJsVariable}

if you use #{yourJsVariable} it shows < >, but with !{} it doesn't.



来源:https://stackoverflow.com/questions/11191421/rendering-html-in-variable-using-jade

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!