46 lines
1.1 KiB
JavaScript
46 lines
1.1 KiB
JavaScript
const log = require('color-logs')(true, true, "Template.class.js"),
|
|
fs = require("fs"),
|
|
hbs = require('handlebars'),
|
|
promise = require('promise'),
|
|
config = require('../config.json');
|
|
|
|
hbs.registerHelper('listNav', function(tabs, options) {
|
|
var out = '';
|
|
for(var x in options['data']['root']){
|
|
out = out + "" + options.fn(options['data']['root'][x]) + "";
|
|
|
|
}
|
|
return out;
|
|
});
|
|
|
|
class Template {
|
|
|
|
/**
|
|
*
|
|
* @returns {Promise} the navbar in html compiled
|
|
*/
|
|
|
|
|
|
|
|
/*getNav(){
|
|
return new Promise((resolve, reject) => {
|
|
fs.readFile('./views/_nav.hbs', 'utf-8', (error, source) => {
|
|
const articles = require("../ressources/categories.json");
|
|
hbs.registerHelper('nav', (nav) =>{
|
|
return nav;
|
|
});
|
|
var template = hbs.compile(source);
|
|
var html = template(articles);
|
|
resolve(html);
|
|
});
|
|
});
|
|
}
|
|
|
|
|
|
getToot(){
|
|
|
|
}*/
|
|
}
|
|
|
|
|
|
module.exports = Template; |