Amy T McBride Amy T McBride - 1 year ago 81
Node.js Question

Default location of express generator title object

I'm using the express generator to create the framework for a site, which by default includes this line in the layout.jade file:

h1= title

Which calls in the title 'Express' from a local variable (index.jade extends the layout.jade file). However, I can't for the life of me find out where it's getting the variable from.

Can anyone tell me where the express generator creates the file that creates this variable, given I have used the default settings.

Answer Source

Inside the routes directory inside the index.js file

var express = require('express');
var router = express.Router();

/* GET home page. */
router.get('/', function(req, res, next) {
 res.render('index', { title: 'Express' }); // <= HERE in the res.render method

module.exports = router;

You will find the object, passed as the second argument to the render method, that includes the key value pair {title: 'Express'}

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download