vendredi 20 février 2015

What is the best way to pass global config variables to handlebars template?


Ive a nodejs app with express-handlebars and i am wanting to define variable for things like the 'host' address for CSS and Javascript that are currently being imported in a header.hbs file that i call form within the specific layout.


Ive created a config.js file which has a number of variables i want to set and ive imported that into the app.js using:



var config = require('./config.js');


but then im lost as t where to go. for example i was thinkging if i can some how do something like this:



<link href="{{config.csshost}}basev1.css" rel="stylesheet" type="text/css" />


Can anyone provide some pointers, am stumped other than declaring these variable every time i load the template.





Aucun commentaire:

Enregistrer un commentaire