Using express-expose and Handlebars.js gives me Unexpected Token &

☆樱花仙子☆ 提交于 2021-01-29 02:50:35

问题


I am using express-expose to pass variables to the clientside so I can use them, however the variables that are being passed are being formatted with "

for example I have.

in my server.js

res.expose('var some = "variable";');
res.render("home");

then in my template i have

<script type="text/javascript">
{{javascript}}
</script>

but it gives me an error and chrome dev tools says

var some = &quot;variable&quot;;
Uncaught SyntaxError: Unexpected token &

回答1:


I got it! Had to use triple stash {{{javascript}}} rather then double stash.



来源:https://stackoverflow.com/questions/13000557/using-express-expose-and-handlebars-js-gives-me-unexpected-token

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