Reputation: 5093
I need to require a util module in my jade template to do some checking.
Can I do that? I tried following in a jade template which sits in $ROOT/views/jade/sample.jade
var utils = require('../../app/server/modules/queries.js')
for a module that sits in
$ROOT/app/server/modules/queries.js
But it does not work.
Can I do what I want????
Upvotes: 3
Views: 1793
Reputation: 10678
You can register helpers from within Express.
In a request handler.
var utils = require('../../app/server/modules/queries.js')
function(req, res) {
res.render("sample", {
locals: {
title: "Welcome to Derpco",
someUtilFunction: utils.someUtilFunction
}
});
};
Also you can register helpers globally using app.locals.helpername = ...
Upvotes: 6