2014-04-17 11:26:18 +00:00
|
|
|
var fs = require('fs');
|
|
|
|
var path = require('path');
|
|
|
|
var handlebars = require('handlebars');
|
|
|
|
|
|
|
|
function compileTemplate(hbsFile) {
|
2014-04-18 22:24:20 +00:00
|
|
|
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
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|