I have a config object that I want to use in pretty much every view on my express appplication. It looks something like this:
{
"url" : "http://whatever.com",
"more" : "yadda yadda"
}
I want to have is accessible to all my views so I can easily reference config.url
Problem is that I don't want to pass this variable every time I do a res.render('viewname')
With express, is it possible to just always have this available? Am I even doing this right or does express have something for this already?
If the properties are static (the same for all requests), use app.locals.
app.locals = {
"url" : "http://whatever.com",
"more" : "yadda yadda"
};
Variables set with app.set() are automatically accessible through settings.x in a view.
See the docs.