Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

expressJs default value of title variable declaration

Where does express get the default value for its title variable. My index.jade looks like the following:

    h1= title
p Welcome to #{title}

I don't quite understand where the title variable is set.

like image 507
Tarang Hirani Avatar asked Feb 03 '26 05:02

Tarang Hirani


1 Answers

In your routes/index.js you will be saying

res.render('index', { title: 'Express' });

So here it will find views/index.jade put value of title variable as 'Express'.

You can say in your jade

p Welcome to #{title} from #{name}

and while renderring

res.render('index', { title: 'Express' ,name: 'myName'});

it will be converted in Welcome to Express from myName.

like image 62
Mritunjay Avatar answered Feb 04 '26 22:02

Mritunjay