Node says Jade has no method “renderFile”, why?

后端 未结 3 578
执念已碎
执念已碎 2021-01-04 11:28

I installed jade (npm install jade) and went over to their github page to grab some examples. This is what I wanted to execute:

code.jade:

- var titl         


        
3条回答
  •  庸人自扰
    2021-01-04 12:02

    The real solution, you need to pass an absolute path as the 1st parameter in the renderFile function. It has to be relative to the root. "code.jade" won't work. Here is a working example:

      jade.renderFile('/Users/tom/documents/xueqiu/pp-fe/views/a-share.jade', {name:'Shenxin Xu'}, function(err, html){
            console.log(1111 + ' ' + html);
          });
    

提交回复
热议问题