Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
app.use('/blind/nunjucks', function(req, res){
if(req.url) {
var url_parts = url.parse(req.url, true);
var inj = url_parts.query.inj;
var tpl = '';
if('tpl' in url_parts.query && url_parts.query.tpl != '') {
// Keep the formatting a-la-python
tpl = url_parts.query.tpl.replace('%s', inj);
}
else {
tpl = inj;
}
nunjucks.renderString(tpl);
res.end(randomstring.generate());
}
});
packageData.pkgName = name
const packageJSON = JSON.parse(readFileSync(`./packages/${name}/package.json`))
packageData.version = packageJSON.version
const markdown = nunjucks.renderString(template, packageData)
writeFileSync(`./packages/${name}/README.md`, markdown)
try {
baseData.packages.push(modelPackage(packageData, baseData))
} catch (e) {
throw new Error(`Missing required fields in package: ${name}\n`)
}
// writeFileSync(`./debug/data-${name}-dump.js`, JSON.stringify(data))
})
// await writeFileSync('./debug/data-root-dump.js', JSON.stringify(rootData))
const markdown = nunjucks.renderString(templateRoot, baseData)
writeFileSync('./README.md', markdown)
}
.add('Nunjucks#renderNoCache', function() {
nunjucks.renderString(str, obj);
})
// add listeners
// Set local variable to directory path.
let directoryPath = directories[dir];
// Change the document root if we need to.
if (info.formio && info.formio.docRoot) {
directoryPath = path.join(directories[dir], info.formio.docRoot);
}
if (!fs.existsSync(path.join(directoryPath, 'config.template.js'))) {
return done('Missing config.template.js file');
}
// Change the project configuration.
const config = fs.readFileSync(path.join(directoryPath, 'config.template.js'));
const newConfig = nunjucks.renderString(config.toString(), {
domain: formio.config.domain ? formio.config.domain : 'https://form.io'
});
fs.writeFileSync(path.join(directoryPath, 'config.js'), newConfig);
done();
});
};
return 1;
} else if (b.default) {
return -1;
}
}
});
_.each(data.sites, function(site) {
delete site._index;
});
var sites = _.filter(data.sites, validSiteFilter);
var template = fs.readFileSync(settings.template || (__dirname + '/template.conf'), 'utf8');
var output = nunjucks.renderString(template, {
sites: sites,
settings: settings
});
// Set up include-able files to allow
// easy customizations
_.each(sites, function(site) {
var folder = settings.overrides;
if (!fs.existsSync(folder)) {
fs.mkdirSync(folder);
}
folder += '/' + site.shortname;
if (!fs.existsSync(folder)) {
fs.mkdirSync(folder);
}
var files = [ 'location', 'proxy', 'server', 'top' ];
module.exports = function bishengEntryLoader(content) {
if (this.cacheable) {
this.cacheable();
}
const query = loaderUtils.parseQuery(this.query);
const config = getConfig(query.config);
const themePath = path.join(process.cwd(), config.theme);
const root = query.isBuild === true ? config.root : '/';
return nunjucks.renderString(content, { themePath, root });
};
module.exports = function(source) {
const isProd = process.env.NODE_ENV === 'production'
const isServer = this.target === 'node'
const rendered = nunjucks.renderString(source, config)
return rendered
}
function getRoutesPath(themePath, configEntryName) {
const routesTemplate = fs.readFileSync(path.join(__dirname, 'routes.nunjucks.js')).toString();
const routesPath = path.join(tmpDirPath, `routes.${configEntryName}.js`);
const { bishengConfig, themeConfig } = context;
fs.writeFileSync(
routesPath,
nunjucks.renderString(routesTemplate, {
themePath: escapeWinPath(themePath),
themeConfig: JSON.stringify(bishengConfig.themeConfig),
themeRoutes: JSON.stringify(themeConfig.routes),
}),
);
return routesPath;
}
function getRoutesPath(themePath, configEntryName) {
const routesTemplate = fs.readFileSync(path.join(__dirname, 'routes.nunjucks.js')).toString();
const routesPath = path.join(tmpDirPath, `routes.${configEntryName}.js`);
const { bishengConfig, themeConfig } = context;
fs.writeFileSync(
routesPath,
nunjucks.renderString(routesTemplate, {
themePath: escapeWinPath(themePath),
themeConfig: JSON.stringify(bishengConfig.themeConfig),
themeRoutes: JSON.stringify(themeConfig.routes),
}),
);
return routesPath;
}