J
J
Jiakki-js2015-05-08 15:48:16
JavaScript
Jiakki-js, 2015-05-08 15:48:16

How not to pass the same thing to res.render()?

There is a master template

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

and another page
res.render('other', {
title: title
menu : menu
})

Values ​​are taken from the database!
How not to repeat?
Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Wolf, 2015-05-08
@Jiakki-js

# index.js
app.locals.title = title;
app.locals.menu = menu;

# view.js
res.render('index');

# other.js
res.render('other');
// index.jade
.title=title
.menu
  .container=menu

Or res.localsfor the current request.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question