2
0
mirror of https://github.com/thumbsup/thumbsup synced 2024-11-17 15:25:50 +00:00
thumbsup/src/render.js

28 lines
601 B
JavaScript
Raw Normal View History

2014-04-17 11:26:18 +00:00
var fs = require('fs');
var path = require('path');
var handlebars = require('handlebars');
function compileTemplate(hbsFile) {
var src = fs.readFileSync(path.join(__dirname, '..', 'templates', hbsFile));
2014-04-17 11:26:18 +00:00
return handlebars.compile(src.toString());
}
var galleryTemplate = compileTemplate('gallery.hbs');
exports.gallery = function(list, active) {
var links = list.map(function(item) {
return {
name: item.name,
url: item.name + '.html',
active: (item === active)
};
});
return galleryTemplate({
links: links,
gallery: active
});
};