Permalink
Browse files

don't remove duplicate tokens when extending

fixes gh-67
  • Loading branch information...
1 parent fdcc8db commit 0a9c503a24c4664c4ef7e6304289df4ffd86f2a8 @paularmstrong committed Apr 1, 2012
Showing with 8 additions and 1 deletion.
  1. +1 −1 lib/parser.js
  2. +7 −0 lib/parser.test.js
View
2 lib/parser.js
@@ -347,7 +347,7 @@ exports.compile = function compile(indent, parentBlock) {
if (tokens.length && tokens[0].name === 'extends') {
this.blocks = _.extend({}, this.parent.blocks, this.blocks);
- this.tokens = _.union(sets, this.parent.tokens);
+ this.tokens = sets.concat(this.parent.tokens);
}
sets = tokens = null;
}
View
7 lib/parser.test.js
@@ -396,5 +396,12 @@ exports.Compiling = testCase({
eval('var _output = "";' + parser.compile.call(template, ''));
}, 'block should throw if nested');
test.done();
+ },
+
+ 'duplicate strings are not removed when extended': function (test) {
+ var dummy = swig.compile('"{{ e }}"{{ f }}"{{ g }}"{{ h }}', { filename: 'foo' }),
+ tpl = '{% extends "foo" %}';
+ test.strictEqual(swig.compile(tpl)({ e: 'e', f: 'f', g: 'g', h: 'h' }), '"e"f"g"h', 'render extended');
+ test.done();
}
});

0 comments on commit 0a9c503

Please sign in to comment.