forked from st8998/commitwall
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.js
35 lines (25 loc) · 952 Bytes
/
helpers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var fs = require('fs');
var _ = require('underscore');
_.mixin(require('underscore.string'));
var _date = require('underscore.date');
assetManager = require('./assets').assetsMiddleware;
function attach(app) {
var templatesCache = {};
app.helpers({
template: function(name) {
if (!templatesCache[name]) {
templatesCache[name] = fs.readFileSync(__dirname + '/views/' + name + '.jade');
}
return '<script type="text/jade-template" id="' + name + 'Template">' + templatesCache[name] + '</script>'
},
javascriptInclude: function(name) {
return '<script type="text/javascript" src="/assets/' + assetManager.cacheTimestamps[name] + '/' + name + '.js"></script>';
},
stylesheetInclude: function(name) {
return '<link rel="stylesheet" href="/assets/' + assetManager.cacheTimestamps[name] + '/' + name + '.css"></script>';
},
_: _,
_date: _date
});
}
exports.attach = attach;