Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
files[path.basename(file, '.js')] = `${projectHelpersDir}/${file}`;
}
});
Object.keys(files).forEach((key) => {
const helperTagFactory = require(files[key]);
// expose helper as custom tag
/* eslint-disable-next-line */
Twig.extend(function(Twig) {
Twig.exports.extendTag(helperTagFactory(Twig));
});
});
// eslint-disable-next-line
Twig.renderWithLayout = (path, options, fn) => {
const layoutPath = `${options.settings.views}/${options.layout}.${options.settings['view engine']}`;
function layoutRendered(error, layout) {
function bodyRendered(body) {
layout = layout.replace('', body);
return fn(null, layout);
}
return Twig.__express(path, options, bodyRendered);
}
return Twig.__express(layoutPath, options, layoutRendered);
};
module.exports = Twig;
projectFiles.map((file) => {
if (path.extname(file) === '.js') {
files[path.basename(file, '.js')] = projectHelpersDir + file;
}
});
Object.keys(files).forEach((key) => {
const helperTagFactory = require(files[key]);
// expose helper as custom tag
Twig.extend(function(Twig) {
Twig.exports.extendTag(helperTagFactory(Twig));
});
});
Twig.renderWithLayout = function(path, options, fn) {
const layoutPath = options.settings.views + '/' + options.layout + '.' + options.settings['view engine'];
function layoutRendered(error, layout) {
function bodyRendered(error, body) {
layout = layout.replace('', body);
return fn(null, layout);
}
return Twig.__express(path, options, bodyRendered);
}
return Twig.__express(layoutPath, options, layoutRendered);
};
module.exports = Twig;