Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
options.functions.forEach(function (func) {
Twig.extendFunction(func.name, func.func);
});
}
module.exports = function () {
'use strict';
/**
* Function for include svg on page
*
* @example svg('path/from/root/dir')
*
* @param path - path from project root dir
*
* TODO: location independence
*
* @returns {String} - svg code
*
*/
twig.extendFunction('svg', function (path) {
return fs.readFileSync(__dirname + '/..' + path, 'utf-8');
});
/**
* Function for getting full named event-type
*
* @usage {{ event.tag | event-type }}
*
* @param eventTag - 'fatal', 'warnings', 'notice' or 'javascript' type of error
*
* @returns {String} - full named event-type
*/
twig.extendFilter('event-type', function (eventTag) {
switch (eventTag) {
case 'fatal':
Object.keys(this.options.functions).forEach(function(name) {
var fn = this.options.functions[name];
if (!isFunction(fn)) {
grunt.fail.fatal('"' + name + '" needs to be a function!');
}
Twig.extendFunction(name, fn);
}.bind(this));
Object.entries(query.functions).forEach(([name, fn]) => Twig.extendFunction(name, fn));
}