How to use the render function from mustache

Find comprehensive JavaScript mustache.render code examples handpicked from public code repositorys.

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.
fork icon180
star icon563
watch icon0

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
fork icon70
star icon422
watch icon3

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 () => {
fork icon181
star icon403
watch icon53

238
239
240
241
242
243
244
245
246
247

            Mustache.parse(template);

            return (context) => {

                return Mustache.render(template, context);
            };
        }
    }
},
fork icon70
star icon194
watch icon19

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)}"`,
fork icon59
star icon210
watch icon14

+ 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,
fork icon22
star icon149
watch icon13

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
fork icon33
star icon120
watch icon25

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 {
fork icon32
star icon44
watch icon10

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.
fork icon29
star icon855
watch icon10

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 });
}


/**
fork icon69
star icon161
watch icon16

+ 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,
);
fork icon2
star icon5
watch icon8

+ 29 other calls in file

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
fork icon449
star icon0
watch icon39

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()));
fork icon8
star icon10
watch icon8

+ 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;
fork icon3
star icon17
watch icon6

+ 3 other calls in file

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()})
fork icon0
star icon5
watch icon2

+ 2 other calls in file

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')
fork icon0
star icon5
watch icon2

+ 3 other calls in file

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({
fork icon0
star icon5
watch icon2

+ 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)
}

/**
fork icon0
star icon2
watch icon1

+ 27 other calls in file

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,
      }
fork icon0
star icon1
watch icon1

+ 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,
fork icon0
star icon1
watch icon1

+ 31 other calls in file