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

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

Leave a Comment