How to use the render function from nunjucks
Find comprehensive JavaScript nunjucks.render code examples handpicked from public code repositorys.
7 8 9 10 11 12 13 14 15 16 17
describe('Template', () => { describe('with default nunjucks configuration', () => { it('should not have any whitespace before the doctype', () => { nunjucks.configure(join(paths.src, 'govuk')) const output = nunjucks.render('./template.njk') expect(output.charAt(0)).toEqual('<') }) })
286
844
60
+ 15 other calls in file
9334 9335 9336 9337 9338 9339 9340 9341 9342 9343
var name = JSON.stringify(templates[i].name); var template = templates[i].template; out += '(function() {' + '(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})' + '[' + name + '] = (function() {\n' + template + '\n})();\n'; if (opts.asFunction) { out += 'return function(ctx, cb) { return nunjucks.render(' + name + ', ctx, cb); }\n'; } out += '})();\n'; }
6
2
2
+ 2 other calls in file
GitHub: lordrepha1980/MobAPI
86 87 88 89 90 91 92 93 94 95
// check if custom template and set template if ( fs.existsSync(`./server/custom/data/${key}.js`) ) Template = `./server/custom/data/${key}.js`; debug('render Template (DATA): ', key); const template = Nunjucks.render(Template, { table: key, collection: key, database: dbType, _dirname }); //write templates fs.writeFileSync(`./server/database/${dbType}/dataApi/${key}.js`, template, err => { if (err)
4
5
6
+ 44 other calls in file
42 43 44 45 46 47 48 49 50 51
convertHtmlToPdf.mockReset() assessmentsApi.getEpisode.mockReset() assessmentsApi.getOffenderData.mockReset() getRegistrations.mockReset() getRoshRiskSummary.mockReset() nunjucks.render.mockReset() getApiToken.mockReset() next.mockReset() mockS3ResponseBody.pipe.mockReset() })
2
0
0
+ 2 other calls in file
43 44 45 46 47 48 49 50 51 52
// hexo.log.info(logname, 'render', data.path); logs.render.push(data.path); writefile(logfile, JSON.stringify(logs, null, 2)); return nunjucks.render(data.path, locals); } /** * compile
1
2
1
+ 15 other calls in file
GitHub: xuxuewen/nunjucks-loader
13 14 15 16 17 18 19 20 21 22
template = template.replace(/\\"/g, "\\\\\""); template = template.replace(/\\'/g, "\\\\\'"); template = compile('`' + template + '`').code; return exportsString + template; } template = nunjucks.render(this.resourcePath,{ njk_global:query.global ||{} }); return template; };
0
0
0
115 116 117 118 119 120 121 122 123 124
} return View.instance; } render(template, data = {}) { if (this.app_element != undefined) { this.app_element.innerHTML = nunjcks.render(template, data); } } } exports.View = View;
0
0
1
424 425 426 427 428 429 430 431 432 433
get_app_element(selector) { View.get().app_element = document.querySelector(selector); } render(template, data = []) { if (this.app_element != undefined) { this.app_element.innerHTML = nunjucks.render(template, data); } } } exports.View = View;
0
0
0
nunjucks.configure is the most popular function in nunjucks (144 examples)