pug-filters
Advanced tools
Comparing version 1.2.4 to 2.0.0
@@ -15,11 +15,5 @@ 'use strict'; | ||
if (node.type === 'Filter') { | ||
handleNestedFilters(node, filters); | ||
handleNestedFilters(node, filters, options); | ||
var text = getBodyAsText(node); | ||
var attrs = getAttributes(node); | ||
var opts = options[node.name] || {}; | ||
Object.keys(opts).forEach(function (opt) { | ||
if (!attrs.hasOwnProperty(opt)) { | ||
attrs[opt] = opts[opt]; | ||
} | ||
}); | ||
var attrs = getAttributes(node, options); | ||
attrs.filename = node.filename; | ||
@@ -30,3 +24,3 @@ node.type = 'Text'; | ||
var firstFilter = node.filters.shift(); | ||
var attrs = getAttributes(firstFilter); | ||
var attrs = getAttributes(firstFilter, options); | ||
var filename = attrs.filename = node.file.fullPath; | ||
@@ -37,3 +31,3 @@ var str = node.file.str; | ||
node.filters.forEach(function (filter) { | ||
var attrs = getAttributes(filter); | ||
var attrs = getAttributes(filter, options); | ||
attrs.filename = filename; | ||
@@ -72,5 +66,5 @@ node.val = filterWithFallback(filter, node.val, attrs); | ||
function handleNestedFilters(node, filters) { | ||
function handleNestedFilters(node, filters, options) { | ||
if (node.block.nodes[0] && node.block.nodes[0].type === 'Filter') { | ||
node.block.nodes[0] = handleFilters(node.block, filters).nodes[0]; | ||
node.block.nodes[0] = handleFilters(node.block, filters, options).nodes[0]; | ||
} | ||
@@ -85,3 +79,3 @@ } | ||
function getAttributes(node) { | ||
function getAttributes(node, options) { | ||
var attrs = {}; | ||
@@ -98,3 +92,9 @@ node.attrs.forEach(function (attr) { | ||
}); | ||
var opts = options[node.name] || {}; | ||
Object.keys(opts).forEach(function (opt) { | ||
if (!attrs.hasOwnProperty(opt)) { | ||
attrs[opt] = opts[opt]; | ||
} | ||
}); | ||
return attrs; | ||
} |
{ | ||
"name": "pug-filters", | ||
"version": "1.2.4", | ||
"version": "2.0.0", | ||
"description": "Code for processing filters in pug templates", | ||
@@ -11,4 +11,4 @@ "keywords": [ | ||
"constantinople": "^3.0.1", | ||
"pug-error": "^1.3.0", | ||
"pug-walk": "^1.0.0", | ||
"pug-error": "^1.3.2", | ||
"pug-walk": "^1.1.0", | ||
"jstransformer": "1.0.0", | ||
@@ -26,10 +26,6 @@ "resolve": "^1.1.6", | ||
"jstransformer-uglify-js": "^1.1.1", | ||
"pug-lexer": "^2.0.2", | ||
"pug-load": "^2.0.0", | ||
"pug-parser": "^2.0.1", | ||
"testit": "^2.0.0" | ||
"pug-lexer": "^2.3.1", | ||
"pug-load": "^2.0.4", | ||
"pug-parser": "^2.0.2" | ||
}, | ||
"scripts": { | ||
"test": "node test" | ||
}, | ||
"repository": { | ||
@@ -36,0 +32,0 @@ "type": "git", |
@@ -5,6 +5,6 @@ var assert = require('assert'); | ||
custom: function (str, options) { | ||
assert(options.opt === 'val'); | ||
assert(options.num === 2); | ||
expect(options.opt).toBe('val'); | ||
expect(options.num).toBe(2); | ||
return 'BEGIN' + str + 'END'; | ||
} | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
86010
10
29
1459
Updatedpug-error@^1.3.2
Updatedpug-walk@^1.1.0