浏览代码

fix a bug in regex generators, make cache global

tags/0.4.0
Ben Cherry 15 年前
父节点
当前提交
e3fe0ae352
共有 1 个文件被更改,包括 4 次插入7 次删除
  1. +4
    -7
      mustache.js

+ 4
- 7
mustache.js 查看文件

@@ -5,6 +5,7 @@
*/

var Mustache = function() {
var regexCache = {};
var Renderer = function() {};

Renderer.prototype = {
@@ -355,13 +356,9 @@ var Mustache = function() {
},

getCachedRegex: function(name, generator) {
if (!this._regexCache) {
this._regexCache = {};
}

var byOtag = this._regexCache[this.otag];
var byOtag = regexCache[this.otag];
if (!byOtag) {
byOtag = this._regexCache[this.otag] = {};
byOtag = regexCache[this.otag] = {};
}

var byCtag = byOtag[this.ctag];
@@ -371,7 +368,7 @@ var Mustache = function() {

var regex = byCtag[name];
if (!regex) {
regex = byCtag[name] = generator(this.ctag, this.otag);
regex = byCtag[name] = generator(this.otag, this.ctag);
}

return regex;


正在加载...
取消
保存