How to use the renderString function from nunjucks

Find comprehensive JavaScript nunjucks.renderString code examples handpicked from public code repositorys.

152
153
154
155
156
157
158
159
160
161
    this.innerHTML = this.template('Ricci')
    this.get('/customer/data').then(d=>{
        const template = $('#customer-data').textContent;
        console.log(template)
        console.log(d)
        this.innerHTML = nunjucks.renderString(template, d);
    });
}

template(name) {
fork icon6
star icon2
watch icon2

+ 2 other calls in file

36
37
38
39
40
41
42
43
44
45
 * @param {import('hexo').Locals} locals
 * @returns
 */
function render(data, locals) {
  if ('text' in data) {
    return nunjucks.renderString(data.text, locals);
  }

  // hexo.log.info(logname, 'render', data.path);
  logs.render.push(data.path);
fork icon1
star icon2
watch icon1

+ 15 other calls in file

161
162
163
164
165
166
167
168
169
170
    }
    // If the file does exist, read it.
    const content = fs.readFileSync(filePath).toString();
    // Tell nunjucks to render the file's content, passing the
    // arguments to it as the "component" object.
    return nunjucks.renderString(content, {video: yt_id});

});

// eleventyConfig.addShortcode("user", function(firstName, lastName) {
fork icon1
star icon1
watch icon2

+ 4 other calls in file

138
139
140
141
142
143
144
145
146
147
148
}


async function scatterFilesV2(templateRoot, instanceRoot, scatterRecipe, params) {
  const p = [];
  for (const recipe of scatterRecipe) {
    const srcName = nunjucks.renderString(recipe.srcName, params);
    const srces = await promisify(glob)(srcName, { cwd: templateRoot });
    const dstDir = Object.prototype.hasOwnProperty.call(recipe, "dstNode") ? path.join(instanceRoot, recipe.dstNode) : instanceRoot;
    const dstName = nunjucks.renderString(recipe.dstName, params);
    for (const src of srces) {
fork icon0
star icon0
watch icon0

+ 11 other calls in file