Skip to content

Commit 5acafd3

Browse files
raymond-lamphillipj
authored andcommitted
Fix custom tags by rolling back #643 & #664 (#670)
Pull requests #643 and #664 together fix the issue reported in issue #617, but the change in behavior is causing semvers concerns. See issue #669. Therefore, roll back #643 and #664 and later reintroduce in next planned major release (v3.0). Fixes #669
1 parent 9578db9 commit 5acafd3

File tree

2 files changed

+2
-50
lines changed

2 files changed

+2
-50
lines changed

mustache.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -444,11 +444,10 @@
444444
*/
445445
Writer.prototype.parse = function parse (template, tags) {
446446
var cache = this.cache;
447-
var cacheKey = template + ':' + (tags || mustache.tags).join(':');
448-
var tokens = cache[cacheKey];
447+
var tokens = cache[template];
449448

450449
if (tokens == null)
451-
tokens = cache[cacheKey] = parseTemplate(template, tags);
450+
tokens = cache[template] = parseTemplate(template, tags);
452451

453452
return tokens;
454453
};

test/parse-test.js

-47
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ var expectations = {
5353
: [ [ '#', 'foo', 0, 8, [ [ '#', 'a', 11, 17, [ [ 'text', ' ', 18, 22 ], [ 'name', 'b', 22, 27 ], [ 'text', '\n', 27, 28 ] ], 30 ] ], 37 ] ]
5454
};
5555

56-
beforeEach(function (){
57-
Mustache.clearCache();
58-
});
59-
6056
describe('Mustache.parse', function () {
6157

6258
for (var template in expectations) {
@@ -107,47 +103,4 @@ describe('Mustache.parse', function () {
107103
});
108104
});
109105

110-
describe('when parsing a template without tags specified followed by the same template with tags specified', function() {
111-
it('returns different tokens for the latter parse', function() {
112-
var template = "{{foo}}[bar]";
113-
var parsedWithBraces = Mustache.parse(template);
114-
var parsedWithBrackets = Mustache.parse(template, ['[', ']']);
115-
assert.notDeepEqual(parsedWithBrackets, parsedWithBraces);
116-
});
117-
});
118-
119-
describe('when parsing a template with tags specified followed by the same template with different tags specified', function() {
120-
it('returns different tokens for the latter parse', function() {
121-
var template = "(foo)[bar]";
122-
var parsedWithParens = Mustache.parse(template, ['(', ')']);
123-
var parsedWithBrackets = Mustache.parse(template, ['[', ']']);
124-
assert.notDeepEqual(parsedWithBrackets, parsedWithParens);
125-
});
126-
});
127-
128-
describe('when parsing a template after already having parsed that template with a different Mustache.tags', function() {
129-
it('returns different tokens for the latter parse', function() {
130-
var template = "{{foo}}[bar]";
131-
var parsedWithBraces = Mustache.parse(template);
132-
133-
var oldTags = Mustache.tags;
134-
Mustache.tags = ['[', ']'];
135-
var parsedWithBrackets = Mustache.parse(template);
136-
Mustache.tags = oldTags;
137-
138-
assert.notDeepEqual(parsedWithBrackets, parsedWithBraces);
139-
});
140-
});
141-
142-
describe('when parsing a template with the same tags second time, return the cached tokens', function () {
143-
it('returns the same tokens for the latter parse', function () {
144-
var template = '{{foo}}[bar]';
145-
var parsedResult1 = Mustache.parse(template);
146-
var parsedResult2 = Mustache.parse(template);
147-
148-
assert.deepEqual(parsedResult1, parsedResult2);
149-
assert.ok(parsedResult1 === parsedResult2);
150-
});
151-
});
152-
153106
});

0 commit comments

Comments
 (0)