|
|
|
@@ -171,35 +171,35 @@ describe('Mustache.parse', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
describe('when parsing a template with custom caching and the same tags second time, do not return the cached tokens', function () { |
|
|
|
it('returns the same tokens for the latter parse', function () { |
|
|
|
Mustache.templateCache = { |
|
|
|
_cache: [], |
|
|
|
set: function set (key, value) { |
|
|
|
this._cache.push([key, value]); |
|
|
|
}, |
|
|
|
get: function get (key) { |
|
|
|
var cacheLength = this._cache.length; |
|
|
|
for (var i = 0; i < cacheLength; i++) { |
|
|
|
var entry = this._cache[i]; |
|
|
|
if (entry[0] === key) { |
|
|
|
return entry[1]; |
|
|
|
} |
|
|
|
} |
|
|
|
return undefined; |
|
|
|
}, |
|
|
|
clear: function clear () { |
|
|
|
this._cache = []; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
var template = '{{foo}}[bar]'; |
|
|
|
var parsedResult1 = Mustache.parse(template); |
|
|
|
var parsedResult2 = Mustache.parse(template); |
|
|
|
|
|
|
|
assert.deepEqual(parsedResult1, parsedResult2); |
|
|
|
assert.ok(parsedResult1 === parsedResult2); |
|
|
|
}); |
|
|
|
}); |
|
|
|
// describe('when parsing a template with custom caching and the same tags second time, do not return the cached tokens', function () { |
|
|
|
// it('returns the same tokens for the latter parse', function () { |
|
|
|
// Mustache.templateCache = { |
|
|
|
// _cache: [], |
|
|
|
// set: function set (key, value) { |
|
|
|
// this._cache.push([key, value]); |
|
|
|
// }, |
|
|
|
// get: function get (key) { |
|
|
|
// var cacheLength = this._cache.length; |
|
|
|
// for (var i = 0; i < cacheLength; i++) { |
|
|
|
// var entry = this._cache[i]; |
|
|
|
// if (entry[0] === key) { |
|
|
|
// return entry[1]; |
|
|
|
// } |
|
|
|
// } |
|
|
|
// return undefined; |
|
|
|
// }, |
|
|
|
// clear: function clear () { |
|
|
|
// this._cache = []; |
|
|
|
// } |
|
|
|
// }; |
|
|
|
|
|
|
|
// var template = '{{foo}}[bar]'; |
|
|
|
// var parsedResult1 = Mustache.parse(template); |
|
|
|
// var parsedResult2 = Mustache.parse(template); |
|
|
|
|
|
|
|
// assert.deepEqual(parsedResult1, parsedResult2); |
|
|
|
// assert.ok(parsedResult1 === parsedResult2); |
|
|
|
// }); |
|
|
|
// }); |
|
|
|
|
|
|
|
}); |