Rendering Templates in a Response

Once you have a template engine defined and configured and have created your templates, you can send a rendered template by using the Express app object or using the Response object. To render a template in the Express app object, you use the app.render() method, shown below:

app.render(view, [locals], callback)

The view parameter specifies the view filename in the views directory. If no extension is included on the file, the default extensions, such as .jade and .ejs, are tried. The locals parameter allows you to pass in a locals object if one has not been defined in app.locals already. The callback function is executed after the template has been rendered and should accept an error ...

Get Node.js, MongoDB, and AngularJS Web Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.