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) }
/** * @description Get the reply for a given intent * @param {string} language - The language of the message. * @param {string} intent - The intent of the message. * @param {Object} context - The context of the conversation. * @returns {string} - Return a text. * @example * brain.getReply('en', 'light.turn-on.success'); */ function getReply(language, intent, context = new ConversationContext()) { const text = this.nlpManager.getAnswer(language, intent, context); if (!text) { throw new NotFoundError(`Answer with intent ${intent} and language ${language} not found`); } return Handlebars.compile(text)(context); }
const contents = fs.readFileSync(includesPath, 'utf-8'); if (includesPath.substr(-4).toLocaleLowerCase() === '.hbs') { const template = Handlebars.compile(contents); return template(context); } else {
var handlebarsPolicyHandler = function(props, context, flow) { var logger = flow.logger; logger.debug('ENTER handlebars policy'); if (_.isUndefined(props.source) || !_.isString(props.source)) { flow.fail({ name: 'HandlebarsError', value: 'Missing Handlebars template' }); return; } if (props.output && !_.isString(props.output)) { flow.fail({ name: 'HandlebarsError', value: 'Invalid output' }); return; } var output = 'message.body'; if (props.output) { output = props.output; } var templateFn; try { templateFn = Handlebars.compile(props.source); context.set(output, templateFn(context)); } catch (e) { flow.fail({ name: 'HandlebarsError', value: 'Invalid Handlebars template' }); return; } logger.debug('EXIT'); flow.proceed(); }
components.edit(function (hbs) { var template = Handlebars.compile(hbs); var html = template(data_create); //console.log(html); resolve(html); });
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 generateModels(state, options){ if (state.dbExists){ readFile(options.pkgDir+'/templates/models.js', options.error, function(err, data){ writeFile( state.location+'/models.js', Handlebars.compile(data)(), options.error ); }); } }
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; }
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); });
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); });
/** * @description Get the reply for a given intent * @param {string} language - The language of the message. * @param {string} intent - The intent of the message. * @param {Object} context - The context of the conversation. * @returns {string} - Return a text. * @example * brain.getReply('en', 'light.turn-on.success'); */ function getReply(language, intent, context = new ConversationContext()) { const text = this.nlpManager.getAnswer(language, intent, context); if (!text) { throw new NotFoundError(`Answer with intent ${intent} and language ${language} not found`); } return Handlebars.compile(text)(context); }