How do I render an EJS template file in Node.js?

前端 未结 8 1750
臣服心动
臣服心动 2020-12-05 05:24

I\'m using Node.js and trying to render an EJS template file. I figured out how to render strings:

    var http = requ         


        
8条回答
  •  盖世英雄少女心
    2020-12-05 05:42

    There is a function in EJS to render files, you can just do:

        ejs.renderFile(__dirname + '/template.ejs', function(err, data) {
            console.log(err || data);
        });
    

    Source: Official EJS documentation

提交回复
热议问题