partials.forEach(function (item) { let partialFile = __base + 'html/templates/partials/' + item + '.hbs'; let partial = handlebars.compile(fs.readFileSync(partialFile, 'utf-8')); handlebars.registerPartial(item, partial); });
// Add all the required partials. function registerPartials (folder) { const partialsFolder = path.join(folder, '_includes') const partials = fs.readdirSync(partialsFolder) .filter(isValidPartial) .reduce((result, partial) => { const ext = path.extname(partial) const fileFullPath = path.join(partialsFolder, partial) const data = fs.readFileSync(fileFullPath, 'utf-8') // Store as `"filename without extension": content`. result[path.basename(partial, ext)] = data return result }, {}) handlebars.registerPartial(partials) }
// Pre-compile email templates to avoid unnecessary parsing at run time. See `src/emails`. const compileEmail = (filename) => { fs.readdirSync('src/emails').forEach((file) => { if (file.endsWith('.hbs')) { const partial = fs.readFileSync(`src/emails/${file}`, 'utf8') .replace(/{{/g, '\\{{') .replace(/\\{{(#block|\/block)/g, '{{$1'); handlebars.registerPartial(file.substr(0, file.length - 4), partial); } }); const template = fs.readFileSync(filename, 'utf8') .replace(/{{/g, '\\{{') .replace(/\\{{(#extend|\/extend|#content|\/content)/g, '{{$1'); return handlebars.precompile(juice(handlebars.compile(template)({}))); }
Handlebars.registerPartial("_quickSummary", Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) { var helper, alias1=helpers.helperMissing, alias2=this.escapeExpression, alias3="function"; return "<ul class=\"list-unstyled quick-summary\">\n <li class=\"qs-item summary-duration\" title=\"Duration\">" + alias2((helpers.formatSummaryDuration || (depth0 && depth0.formatSummaryDuration) || alias1).call(depth0,(depth0 != null ? depth0.duration : depth0),{"name":"formatSummaryDuration","hash":{},"data":data})) + "<span>" + alias2((helpers.getSummaryDurationUnits || (depth0 && depth0.getSummaryDurationUnits) || alias1).call(depth0,(depth0 != null ? depth0.duration : depth0),{"name":"getSummaryDurationUnits","hash":{},"data":data})) + "</span></li>\n <li class=\"qs-item summary-suites\" title=\"Suites\">" + alias2(((helper = (helper = helpers.suites || (depth0 != null ? depth0.suites : depth0)) != null ? helper : alias1),(typeof helper === alias3 ? helper.call(depth0,{"name":"suites","hash":{},"data":data}) : helper))) + "</li>\n <li class=\"qs-item summary-tests\" title=\"Tests\">" + alias2(((helper = (helper = helpers.testsRegistered || (depth0 != null ? depth0.testsRegistered : depth0)) != null ? helper : alias1),(typeof helper === alias3 ? helper.call(depth0,{"name":"testsRegistered","hash":{},"data":data}) : helper))) + "</li>\n <li class=\"qs-item summary-passes\" title=\"Passed\" data-filter=\"passed\">" + alias2(((helper = (helper = helpers.passes || (depth0 != null ? depth0.passes : depth0)) != null ? helper : alias1),(typeof helper === alias3 ? helper.call(depth0,{"name":"passes","hash":{},"data":data}) : helper))) + "</li>\n <li class=\"qs-item summary-failures\" title=\"Failed\" data-filter=\"failed\">" + alias2(((helper = (helper = helpers.failures || (depth0 != null ? depth0.failures : depth0)) != null ? helper : alias1),(typeof helper === alias3 ? helper.call(depth0,{"name":"failures","hash":{},"data":data}) : helper))) + "</li>\n <li class=\"qs-item summary-pending\" title=\"Pending\" data-filter=\"pending\">" + alias2(((helper = (helper = helpers.pending || (depth0 != null ? depth0.pending : depth0)) != null ? helper : alias1),(typeof helper === alias3 ? helper.call(depth0,{"name":"pending","hash":{},"data":data}) : helper))) + "</li>\n</ul>"; },"useData":true}));
function registerTemplates() { const partials = [ 'App', 'AppStatus', 'Tags', 'Networks' ]; partials.forEach((partial) => { Handlebars.registerPartial(partial, FS.readFileSync(`${__dirname}/html/partials/${partial}.html`, { encoding: 'utf8' })); }); mainTemplate = Handlebars.compile(FS.readFileSync(`${__dirname}/html/Main.html`, { encoding: 'utf8' })); appTemplate = Handlebars.compile('{{> App}}'); appStatusTemplate = Handlebars.compile('{{> AppStatus}}'); tagsTemplate = Handlebars.compile('{{> Tags}}'); networksTemplate = Handlebars.compile('{{> Networks}}'); }
const data = this.getFile(`./partials/${fileName}`); this.hbs.registerPartial(fileName, data); this.partials.push(fileName); Promise.resolve();
Handlebars.registerPartial("_statusbar", Handlebars.template({"1":function(depth0,helpers,partials,data) { var helper, alias1=helpers.helperMissing, alias2=this.escapeExpression;
Handlebars.registerPartial("_summary", Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) { var helper, alias1=helpers.helperMissing, alias2=this.escapeExpression, alias3="function"; return "<div class=\"row\">\n <div class=\"summary-col summary-duration\">\n <h1 class=\"summary-count\">" + alias2((helpers.formatSummaryDuration || (depth0 && depth0.formatSummaryDuration) || alias1).call(depth0,(depth0 != null ? depth0.duration : depth0),{"name":"formatSummaryDuration","hash":{},"data":data})) + "<span>" + alias2((helpers.getSummaryDurationUnits || (depth0 && depth0.getSummaryDurationUnits) || alias1).call(depth0,(depth0 != null ? depth0.duration : depth0),{"name":"getSummaryDurationUnits","hash":{},"data":data})) + "</span></h1>\n <h4 class=\"summary-label\">" + alias2((helpers.getSummaryDurationUnits || (depth0 && depth0.getSummaryDurationUnits) || alias1).call(depth0,(depth0 != null ? depth0.duration : depth0),{"name":"getSummaryDurationUnits","hash":{},"data":data})) + "</h4>\n </div>\n <div class=\"summary-col summary-suites\" title=\"Suites\">\n <h1 class=\"summary-count\">" + alias2(((helper = (helper = helpers.suites || (depth0 != null ? depth0.suites : depth0)) != null ? helper : alias1),(typeof helper === alias3 ? helper.call(depth0,{"name":"suites","hash":{},"data":data}) : helper))) + "</h1>\n <h4 class=\"summary-label\">Suite" + alias2((helpers.getPlural || (depth0 && depth0.getPlural) || alias1).call(depth0,(depth0 != null ? depth0.suites : depth0),{"name":"getPlural","hash":{},"data":data})) + "</h4>\n </div>\n <div class=\"summary-col summary-tests\" title=\"Tests\">\n <h1 class=\"summary-count\">" + alias2(((helper = (helper = helpers.testsRegistered || (depth0 != null ? depth0.testsRegistered : depth0)) != null ? helper : alias1),(typeof helper === alias3 ? helper.call(depth0,{"name":"testsRegistered","hash":{},"data":data}) : helper))) + "</h1>\n <h4 class=\"summary-label\">Test" + alias2((helpers.getPlural || (depth0 && depth0.getPlural) || alias1).call(depth0,(depth0 != null ? depth0.testsRegistered : depth0),{"name":"getPlural","hash":{},"data":data})) + "</h4>\n </div>\n <div class=\"summary-col summary-passes\" data-filter=\"passed\" title=\"Passed\">\n <h1 class=\"summary-count\">" + alias2(((helper = (helper = helpers.passes || (depth0 != null ? depth0.passes : depth0)) != null ? helper : alias1),(typeof helper === alias3 ? helper.call(depth0,{"name":"passes","hash":{},"data":data}) : helper))) + "</h1>\n <h4 class=\"summary-label\">Passed</h4>\n </div>\n <div class=\"summary-col summary-failures\" data-filter=\"failed\" title=\"Failed\">\n <h1 class=\"summary-count\">" + alias2(((helper = (helper = helpers.failures || (depth0 != null ? depth0.failures : depth0)) != null ? helper : alias1),(typeof helper === alias3 ? helper.call(depth0,{"name":"failures","hash":{},"data":data}) : helper))) + "</h1>\n <h4 class=\"summary-label\">Failed</h4>\n </div>\n <div class=\"summary-col summary-pending\" data-filter=\"pending\" title=\"Pending\">\n <h1 class=\"summary-count\">" + alias2(((helper = (helper = helpers.pending || (depth0 != null ? depth0.pending : depth0)) != null ? helper : alias1),(typeof helper === alias3 ? helper.call(depth0,{"name":"pending","hash":{},"data":data}) : helper))) + "</h1>\n <h4 class=\"summary-label\">Pending</h4>\n </div>\n</div>"; },"useData":true}));
]; partials.forEach((partial) => { Handlebars.registerPartial(partial, FS.readFileSync(`${__dirname}/html/partials/${partial}.html`, { encoding: 'utf8' })); }); const template = Handlebars.compile(FS.readFileSync(`${__dirname}/html/Applications.html`, { encoding: 'utf8' }));
Handlebars.registerPartial("_test", Handlebars.template({"1":function(depth0,helpers,partials,data) { return " passed"; },"3":function(depth0,helpers,partials,data) {
function registerTemplates() { const partials = [ 'EditTable', 'ShowTable', 'SelectDirectory', 'SelectShares', 'EditShares', 'SelectWebsites', 'Disks', 'BackupAndRestore', 'DownloadFile', 'SelectBackups' ]; partials.forEach((partial) => { Handlebars.registerPartial(partial, Handlebars.compile( FS.readFileSync(`${__dirname}/html/partials/${partial}.html`, { encoding: 'utf8' }), { preventIndent: true })); }); template = Handlebars.compile(FS.readFileSync(`${__dirname}/html/Configure.html`, { encoding: 'utf8' }), { preventIndent: true }); downloadTemplate = Handlebars.compile('{{> DownloadFile}}', { preventIndent: true }); websitesTemplate = Handlebars.compile('{{> SelectWebsites}}', { preventIndent: true }); }
const data = this.getFile(`./partials/${fileName}`); this.hbs.registerPartial(fileName, data); this.partials.push(fileName); Promise.resolve();