express - require an external module in jade in a node.js webserver -


i need require util module in jade template checking.

can that? tried following in jade template sits in $root/views/jade/sample.jade

var utils = require('../../app/server/modules/queries.js') 

for module sits in

$root/app/server/modules/queries.js 

but not work.

can want????

you can register helpers within express.

in request handler.

var utils = require('../../app/server/modules/queries.js') function(req, res) {   res.render("sample", {     locals: {       title: "welcome derpco",       someutilfunction: utils.someutilfunction     }   }); }; 

also can register helpers globally using app.locals.helpername = ...


Comments

Popular posts from this blog

ruby on rails - Is it the correct way to implement belongs_to relation with factory girl? -

geolocation - Windows Phone 8 - Keeping background location tracking active beyond four hours -

Uncaught TypeError: Cannot read property 'parentNode' of null javascript -