htmltemplate-transform
Advanced tools
Comparing version 1.0.7 to 1.0.8
{ | ||
"name": "htmltemplate-transform", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "Pluggable transforms for HTML::Template", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -29,23 +29,5 @@ var assert = require('assert'); | ||
updatedContent.push( | ||
assignTag(breakId, 1), | ||
{ | ||
type: 'Tag', | ||
name: 'TMPL_ASSIGN', | ||
attributes: [ | ||
{ | ||
type: 'SingleAttribute', | ||
name: breakId, | ||
value: null, | ||
position: node[breakIndex].position | ||
}, | ||
{ | ||
type: 'Expression', | ||
content: { | ||
type: 'Literal', | ||
value: 1 | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
type: 'Tag', | ||
name: 'TMPL_CONTINUE' | ||
@@ -97,7 +79,26 @@ } | ||
breaks = []; | ||
this.update( | ||
assign({}, node, { content: updatedContent }), | ||
true | ||
); | ||
// Reset "break" flags after the loop is run. | ||
var unassignments = breaks.map(function(breakId) { | ||
return assignTag(breakId, 0); | ||
}); | ||
this.parent.post(function() { | ||
this.update( | ||
this.node.reduce(function(content, child) { | ||
if (child === node) { | ||
var updatedNode = assign({}, node, { content: updatedContent }); | ||
content.push(updatedNode); | ||
content.push.apply(content, unassignments); | ||
} else { | ||
content.push(child); | ||
} | ||
return content; | ||
}, []), | ||
true | ||
); | ||
breaks = []; | ||
}); | ||
} | ||
@@ -109,2 +110,23 @@ }); | ||
function assignTag(name, value) { | ||
return { | ||
type: 'Tag', | ||
name: 'TMPL_ASSIGN', | ||
attributes: [ | ||
{ | ||
type: 'SingleAttribute', | ||
name: name, | ||
value: null | ||
}, | ||
{ | ||
type: 'Expression', | ||
content: { | ||
type: 'Literal', | ||
value: value | ||
} | ||
} | ||
] | ||
}; | ||
} | ||
function findIndex(list, predicate) { | ||
@@ -111,0 +133,0 @@ for (var i = 0, len = list.length; i < len; i += 1) { |
@@ -149,7 +149,3 @@ [ | ||
"name": "b_l___br0", | ||
"value": null, | ||
"position": { | ||
"line": 10, | ||
"column": 9 | ||
} | ||
"value": null | ||
}, | ||
@@ -319,2 +315,20 @@ { | ||
{ | ||
"type": "Tag", | ||
"name": "TMPL_ASSIGN", | ||
"attributes": [ | ||
{ | ||
"type": "SingleAttribute", | ||
"name": "b_l___br0", | ||
"value": null | ||
}, | ||
{ | ||
"type": "Expression", | ||
"content": { | ||
"type": "Literal", | ||
"value": 0 | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "Text", | ||
@@ -321,0 +335,0 @@ "content": "\n", |
@@ -153,7 +153,3 @@ [ | ||
"name": "b_l___br0", | ||
"value": null, | ||
"position": { | ||
"line": 8, | ||
"column": 9 | ||
} | ||
"value": null | ||
}, | ||
@@ -234,7 +230,3 @@ { | ||
"name": "b_l___br1", | ||
"value": null, | ||
"position": { | ||
"line": 11, | ||
"column": 9 | ||
} | ||
"value": null | ||
}, | ||
@@ -404,2 +396,38 @@ { | ||
{ | ||
"type": "Tag", | ||
"name": "TMPL_ASSIGN", | ||
"attributes": [ | ||
{ | ||
"type": "SingleAttribute", | ||
"name": "b_l___br0", | ||
"value": null | ||
}, | ||
{ | ||
"type": "Expression", | ||
"content": { | ||
"type": "Literal", | ||
"value": 0 | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "Tag", | ||
"name": "TMPL_ASSIGN", | ||
"attributes": [ | ||
{ | ||
"type": "SingleAttribute", | ||
"name": "b_l___br1", | ||
"value": null | ||
}, | ||
{ | ||
"type": "Expression", | ||
"content": { | ||
"type": "Literal", | ||
"value": 0 | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "Text", | ||
@@ -406,0 +434,0 @@ "content": "\n", |
@@ -9,3 +9,3 @@ var fs = require('fs'); | ||
describe('replace-break transform', function() { | ||
['001', '002'].forEach(function(n) { | ||
['001', '002', '003'].forEach(function(n) { | ||
var filename = 'template.' + n + '.tmpl'; | ||
@@ -12,0 +12,0 @@ |
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
290189
62
7134