How to use the render function from mustache
Find comprehensive JavaScript mustache.render code examples handpicked from public code repositorys.
GitHub: hypothesis/client
35 36 37 38 39 40 41 42 43 44 45
let clientUrl = '{{{clientUrl}}}'.replace('{current_host}', document.location.hostname); loadClient(clientUrl); })(); </script> `; return Mustache.render(scriptTemplate, context); } /** * Read tags in test pages specifying custom headers to serve the content with.
180
563
0
14 15 16 17 18 19 20 21 22
obj[key] = value return obj }, {}) // Merge collection vars with additional vars const context = { ...formatVars, ...additionalVars } return Mustache.render(collectionString, context) } module.exports = replacePostmanVariables
70
422
3
GitHub: medic/cht-core
661 662 663 664 665 666 667 668 669 670 671 672
for (const file of COMPOSE_FILES) { const templatePath = getTemplateComposeFilePath(file); const testComposePath = getTestComposeFilePath(file); const template = await fs.promises.readFile(templatePath, 'utf-8'); await fs.promises.writeFile(testComposePath, mustache.render(template, view)); } }; const createLogDir = async () => {
181
403
53
GitHub: hapijs/vision
238 239 240 241 242 243 244 245 246 247
Mustache.parse(template); return (context) => { return Mustache.render(template, context); }; } } },
70
194
19
68 69 70 71 72 73 74 75 76 77
) } } return { path: Mustache.render(this.globalArgs.pathTemplate, { args }), assert: this.globalArgs.assertTemplate ? Mustache.render(this.globalArgs.assertTemplate, { args }) : null } } else { if (!args || args.length === 0 || args.length > 2) { throw new BotiumError(`${convoStep.stepTag}: ${this.name} 1 or 2 arguments expected "${toString(args)}"`,
59
210
14
+ 3 other calls in file
46 47 48 49 50 51 52 53 54 55
if (this.statusCode == 0) { err = 'wait'; } var data = fs.readFileSync(this.getPath('media/result.tmpl'), 'utf-8'); var result = Mustache.render(data, { fontSize: config.get('editor.fontSize'), fontFamily: config.get('editor.fontFamily'), header: header, err: err,
22
149
13
109 110 111 112 113 114 115 116 117 118
buildViewModel(app, event, function (err, viewModel) { if (err) return done(err); const text = mustache.render(messageTemplate, viewModel); async.each(targets, function (target, callback) { // Payload depends on type of messenger // Post to the hook URL
33
120
25
71 72 73 74 75 76 77 78 79 80
console.log("Javascript Compilation Error", jserr); return; // Abort! } if (typeof bindme.meta.before_render === "function") { bindme.meta.before_render(); } resolve({ html: Mustache.render(formula, bindme), after_render: bindme.meta.after_render }); } else {
32
44
10
GitHub: poppinss/youch
150 151 152 153 154 155 156 157 158 159
* @param {Object} * * @return {String} */ _compileView (view, data) { return Mustache.render(view, data) } /** * Serializes frame to a usable error object.
29
855
10
230 231 232 233 234 235 236 237 238 239 240
*/ async function renderServiceWorker(serviceWorkerTemplate, view) { let path = rootDir + "/service-worker.js"; let swCode = await readFile(serviceWorkerTemplate, { encoding: "utf-8" }); view.timestamp = new Date().getTime().toString(); swCode = mustache.render(swCode.toString(), view); await writeFile({ path: path, content: swCode }); } /**
69
161
16
+ 7 other calls in file
72 73 74 75 76 77 78 79 80 81
// console.log('template:', template); // console.log('preprocessed:', partialData); // console.log('partials:', this.templates.partials); return Mustache.render( template, partialData, this.templates.partials, );
2
5
8
+ 29 other calls in file
GitHub: mashpie/i18n-node
624 625 626 627 628 629 630 631 632 633
msg = printf(msg, Number(count)) } // if the msg string contains {{Mustache}} patterns we render it as a mini template if (!mustacheConfig.disable && mustacheRegex.test(msg)) { msg = Mustache.render(msg, namedValues, {}, mustacheConfig.tags) } // if we have extra arguments with values to get replaced, // an additional substition injects those strings afterwards
449
0
39
GitHub: apigee/edge-launchpad
102 103 104 105 106 107 108 109 110
if(orgDetails && orgDetails.org) this.setVariable('org', mustache.render(orgDetails.org, this.getAllVariables())); if(orgDetails && orgDetails.env) this.setVariable('env', mustache.render(orgDetails.env, this.getAllVariables())); if(orgDetails && orgDetails.token) this.setVariable('token', mustache.render(orgDetails.token, this.getAllVariables()));
8
10
8
+ 11 other calls in file
40 41 42 43 44 45 46 47 48
delete msg.firestore; } const col = input.collection || Mustache.render(this.collection, msg); const group = input.group || this.group; const doc = input.document || Mustache.render(this.document, msg); const rt = input.realtime || this.realtime; const query = input.query || this.query; const disable = input.disableHandler || false;
3
17
6
+ 3 other calls in file
GitHub: giloutho/Logfly
64 65 66 67 68 69 70 71 72 73
log.error('[problem.js] Error while loading the language file') } let menuOptions = menuFill.fillMenuOptions(i18n) $.get('../../views/tpl/sidebar.html', function(templates) { var template = $(templates).filter('#temp-menu').html() var rendered = Mustache.render(template, menuOptions) document.getElementById('target-sidebar').innerHTML = rendered }) btnSelect.innerHTML = i18n.gettext('Select a file') btnSelect.addEventListener('click', (event) => {callDisk()})
0
5
2
+ 2 other calls in file
GitHub: giloutho/Logfly
53 54 55 56 57 58 59 60 61 62
log.error('[problem.js] Error while loading the language file') } let menuOptions = menuFill.fillMenuOptions(i18n) $.get('../../views/tpl/sidebar.html', function(templates) { const template = $(templates).filter('#temp-menu').html() const rendered = Mustache.render(template, menuOptions) document.getElementById('target-sidebar').innerHTML = rendered }) document.getElementById("txt-download").innerHTML = i18n.gettext("Downloading digital elevation data") document.getElementById('fullmap').innerHTML = i18n.gettext('Full screen map')
0
5
2
+ 3 other calls in file
GitHub: giloutho/Logfly
75 76 77 78 79 80 81 82 83 84
log.error('[problem.js] Error while loading the language file') } // let menuOptions = menuFill.fillMenuOptions(i18n) // $.get('../../views/tpl/sidebar.html', function(templates) { // const template = $(templates).filter('#temp-menu').html() // const rendered = Mustache.render(template, menuOptions) // document.getElementById('target-sidebar').innerHTML = rendered // }) translateLabels() const maskLatDd = new Inputmask({
0
5
2
+ 7 other calls in file
331 332 333 334 335 336 337 338 339 340
hasButtons: true, } if (templateVars.buttons.length === 0) { templateVars.hasButtons = false } var template = Mustache.render(dialogTemplate, templateVars) return this.showModalDialogUsingTemplate(template, autoDismiss) } /**
0
2
1
+ 27 other calls in file
GitHub: drafwodgaming/Lusty
99 100 101 102 103 104 105 106 107 108
*/ const embedTitle = locales[locale].embeds.commands.userInfo.title.name; const embedFields = [ { name: locales[locale].embeds.commands.userInfo.fields.createdAd.name, value: mustache.render( locales[locale].embeds.commands.userInfo.fields.createdAd.createdTime, { userCreatedAt: userCreatedAt, }
0
1
1
+ 8 other calls in file
139 140 141 142 143 144 145 146 147 148
{ const welcomeChannel = await welcomeChannelSchema.findOne({ guildId: interactionGuildId, }); const editChannelDescription = mustache.render( locales[locale].embeds.commands.setupGeneral.welcomeChannel .description.editedChannel, { interactionChannelId: interactionChannel.id,
0
1
1
+ 31 other calls in file
mustache.render is the most popular function in mustache (968 examples)