Skip to content

Instantly share code, notes, and snippets.

@ganeshkbhat
Last active October 4, 2018 06:15
Show Gist options
  • Save ganeshkbhat/d3593030a48e2f7f083891229fd717ba to your computer and use it in GitHub Desktop.
Save ganeshkbhat/d3593030a48e2f7f083891229fd717ba to your computer and use it in GitHub Desktop.
ExpressJS Series: Addig a Template engine and usage
/* OTHER CODES */
// Set TEMPLATING Engine views folder
app.set('views', './views');
// Setting Pug as Templating engine
app.set('view engine', 'pug');
// Sends response from the template views/index
// Data of object {status:'running'} is provided/injected to the template and ...
// ... can be accessed there
app.get("/template", function(req, res) {
res.status(200)
.render('index', {title: 'My Pug page', status:'running'});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment