Can I use dynamicHelpers (expressjs) with extend parameters?
Problem
(How) can I use dynamicHelpers with Extend Parameters like this?
app.dynamicHelpers({
getImageUrl: function (req, res, imageName) {
return "http://" + req.headers.host + app.set("imageUrl")+"/" + imageName;
}
});
how can I call this from my template engine?
Problem courtesy of: Rheinprinz
Solution
You return a function from your function:
app.dynamicHelpers({
getImageUrl: function (req, res) {
return function(imageName) {
return "http://" + req.headers.host + app.set("imageUrl") + "/" + imageName;
}
}
});
In your template, you use getImageUrl("some image.jpg")
.
Solution courtesy of: Linus Gustav Larsson Thiel
Discussion
View additional discussion.