I'm currently using EJS templating engine to render my HTML pages, but I want to add underscore to simplify the pre-processing. Right now I do this and it works:
var _ = require("underscore");
app.get('/', function(req, res){
var data = {};
data.people = [{ name: "john" }, { name: "marry" }];
data._ = _; // inject underscore.js
res.render('index', data);
});
Now to render the HTML I have access to underscore:
<% _.each(people, function(person){ %>
<div><%= person.name %></div>
<% }); %>
However, I have to inject underscore for every route, is there a way to always inject underscore? (maybe somewhere in app.engine setting ?)