How to generate a pure JavaScript file with Jade

空扰寡人 提交于 2019-12-05 11:15:41

Produce all XML, include HTML. And jade was not designed to cast large blocks of javascript. The best thing you can do is create a method for obtaining these large blocks, and modifying variables. As it is doing in Example.

I think you should use:

res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Content-Type', 'text/javascript; charset=utf-8');
res.end(`(function(){
    //Some JavaScript Code
    var foo="${bar}";
    console.log("This a JavaScript file generated with Jade");
})()`);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!