New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: cache actually not working #663
Comments
The problem code may be in Writer.prototype.parse: Writer.prototype.parse = function parse (template, tags) {
var cache = this.cache;
var tokens = cache[template];
if (tokens == null)
tokens = cache[template + ':' + (tags || mustache.tags).join(':')] = parseTemplate(template, tags);
return tokens;
}; The problem is the used cache key is different between the time set a cache and the time try to get a cache.
|
My fault. I’ll submit a PR to fix today.
Raymond Lam
… On Jul 15, 2018, at 8:46 AM, Ashinoko ***@***.***> wrote:
When parsing a template with the same tags second time, because of cache, it should return the cached tokens.
test code:
describe('when parsing a template with the same tags second time, return the cached tokens', function () {
it('returns the same tokens for the latter parse', function () {
var template = '{{foo}}[bar]';
var parsedResult1 = Mustache.parse(template);
var parsedResult2 = Mustache.parse(template);
assert.deepEqual(parsedResult1, parsedResult2);
assert.ok(parsedResult1 === parsedResult2);
});
});
test code failed on assert.ok(parsedResult1 === parsedResult2);
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
No rush. Actually, I'm also writing a PR to fix it. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When parsing a template with the same tags second time, because of cache, it should return the cached tokens.
test code:
test code failed on
assert.ok(parsedResult1 === parsedResult2);
The text was updated successfully, but these errors were encountered: