Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} else {
return url
}
})
// Add environment variables as global Nunjucks variable
env.addGlobal('process', {
env: {
NODE_ENV: process.env.NODE_ENV,
PANGOLIN_ENV: process.env.PANGOLIN_ENV
}
})
// Add Pangolin templates as global Nunjucks variable
env.addGlobal('pangolin', {
head: new nunjucks.Template(docsTemplates.head, env).render()
})
// Add metadata as global Nunjucks variable
env.addGlobal('page', pageMeta)
env.addGlobal('site', siteMeta)
// Render page and return results via webpack callback
env.renderString(template, (error, result) => {
if (error) return callback(error)
// Pass content to next loader
callback(null, result)
})
}
nunjucksEnv.addFilter("instantiate", function (input) {
var tmpl = new nunjucks.Template(input);
return tmpl.render(this.getVariables());
});
nunjucksEnv.addFilter("instantiate", function(input) {
var tmpl = new nunjucks.Template(input);
return tmpl.render(this.getVariables());
});
const sidebar = () => {
let html = new nunjucks.Template(templates.sidebar, env).render({
components: pageObjects(context, 'components', file),
prototypes: pageObjects(context, 'prototypes', file)
})
return new nunjucks.runtime.SafeString(html)
}
const components = () => {
return new nunjucks.Template(templates.components, env)
}
const footer = () => {
let html = new nunjucks.Template(templates.footer, env).render()
return new nunjucks.runtime.SafeString(html)
}
var fs = require('fs');
var bench = require('bench');
var oldNunjucks = require('nunjucks');
var nunjucks = require('../index');
var src = fs.readFileSync('case.html', 'utf-8');
var oldEnv = new oldNunjucks.Environment(null);
var oldTmpl = new oldNunjucks.Template(src, env, null, null, true);
var env = new nunjucks.Environment(null);
var tmpl = new nunjucks.Template(src, env, null, null, true);
var ctx = {
items: [
{
current: true,
name: "James"
},
{
name: "Foo",
url: "http://example.com"
},
{
name: "Foo",
const head = () => {
let html = new nunjucks.Template(templates.head, env).render()
return new nunjucks.runtime.SafeString(html)
}
nunjucksEnv.addFilter("instantiate", function (input) {
var tmpl = new nunjucks.Template(input);
return tmpl.render(this.getVariables());
});