function renderPost (results) { const templateStr = fs.readFileSync(path.resolve(__dirname, 'release.hbs')).toString('utf8') const template = Handlebars.compile(templateStr, { noEscape: true }) const view = Object.assign({ date: new Date().toISOString(), versionSlug: slugify(results.version) }, results) return Object.assign({ content: template(view) }, results) }
if (includesPath.substr(-4).toLocaleLowerCase() === '.hbs') { const template = Handlebars.compile(contents); return template(context); } else { return contents;
function buildPages(files) { files.forEach((file) => { let HTMLPath = path.join(__dirname, `../views/views-content/${file}`); // Compile template let template = handlebars.compile(fs.readFileSync(HTMLPath, 'utf8')); // Render template let render = template(); fs.writeFileSync(path.join(output, file), render); }); }
function compile(key, data) { let template = Handlebars.compile(strings.get(key), { noEscape: true }); let compiled = template(data); return emoji.emojify(compiled); }
/** * Generate mjmlContent from the config and feeds set in the constructor * @returns {Email} */ async generate() { const source = await getTemplateFile(this.config.templateUrl); const template = handlebars.compile(source); this.mjmlContent = template({ ...this.config, feeds: this.feeds }); return this; }
components.edit(function (hbs) { var template = Handlebars.compile(hbs); var html = template(data_create); //console.log(html); resolve(html); });
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}));
app.use(router.get('/coronavirus/index', async ({params, route, res}, next) => { const {getCoronavirusKeyIndex} = require('./lib/module/mock'); const index = getCoronavirusKeyIndex(); if(params.type === 'json') { res.setHeader('Content-Type', 'application/json'); res.body = {data: index}; } else { const handlebars = require('handlebars'); const tpl = fs.readFileSync('./view/coronavirus_index.html', {encoding: 'utf-8'}); const template = handlebars.compile(tpl); const result = template({data: index}); res.setHeader('Content-Type', 'text/html'); res.body = result; await next(); } }));
templateList.forEach(function (templateName) { let templateFile = __base + 'html/templates/' + templateName + '.hbs'; logger.debug('reading temple file: %s', templateFile); fs.readFile(templateFile, 'utf-8', function (error, source) { logger.debug('source is type: %s', Object.prototype.toString.apply(source)); const template = handlebars.compile(source); const html = template(data); // copy html to <dir>/reports/index.html const htmlFile = path.join(reportPath, templateName + '.html'); fs.writeFile(htmlFile, html, 'utf8', function (err) { if (err) { logger.error('error writing html file (%s) disk with error: %s', htmlFile, err); } }); if (error) { logger.error('Error reading template file %s, error details: %s', templateFile, error); } }); });
function handleProductsPage(requestUrl, response) { response.writeHead(200); response.write(template({ products: products })); response.end(); }
const compileHtml = (title, text) => { const templatePath = path.resolve(__dirname, '../templates/email.handlebars'); const fileContent = fs.readFileSync(templatePath).toString(); const template = handlebars.compile(fileContent); return template({ title, text }); }
app.use(router.get('/coronavirus/:date', async ({params, route, res}, next) => { const {getCoronavirusByDate} = require('./lib/module/mock'); const data = getCoronavirusByDate(route.date); if(params.type === 'json') { res.setHeader('Content-Type', 'application/json'); res.body = {data}; } else { const handlebars = require('handlebars'); const tpl = fs.readFileSync('./view/coronavirus_date.html', {encoding: 'utf-8'}); const template = handlebars.compile(tpl); const result = template({data}); res.setHeader('Content-Type', 'text/html'); res.body = result; } await next(); }));
components.create(function (hbs) { var template = Handlebars.compile(hbs); var html = template(data_create); //console.log(html); resolve(html); });
components.index(function (hbs) { var template = Handlebars.compile(hbs); var html = template(data_list); //console.log(html); resolve(html); });
components.show(function (hbs) { var template = Handlebars.compile(hbs); var html = template(data_list); //console.log(html); resolve(html); });