javascript - How to add stringified script tag in express + jade/pug -
i have express using pug view. index.pug has following:
script(type='text/javascript'). window.__data__ = !{payload}
where payload json object. has been stringified in render function of express:
res.render('index', { payload : json.stringify({ "anexample": "<script></script>" }) })
when json object has </script>
terminates window.__data =
function due ending script tag. how can prevent blowing page? limitation of pug or express or browser?
you're going have "break up" string containing script tags.
something should work:
"anexample": "<script></scr" + "ipt>"
this way, </scr" + "ipt>
won't interpreted closing script tag.
Comments
Post a Comment