From 64c9fdcc28333c7310df8d9efb9040dbe3b4f8c8 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sat, 1 Jun 2013 16:38:35 +0200 Subject: [PATCH 1/2] Speed up octemplate rendering. --- core/js/octemplate.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/core/js/octemplate.js b/core/js/octemplate.js index e032506c0b..352a23c4dc 100644 --- a/core/js/octemplate.js +++ b/core/js/octemplate.js @@ -60,11 +60,9 @@ var self = this; if(typeof this.options.escapeFunction === 'function') { - $.each(this.vars, function(key, val) { - if(typeof val === 'string') { - self.vars[key] = self.options.escapeFunction(val); - } - }); + for (var key = 0; key < this.vars.length; key++) { + this.vars[key] = self.options.escapeFunction(this.vars[key]); + } } var _html = this._build(this.vars); From bfcf113ce7e4293c955fd76e51e4515f29232b94 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Sat, 1 Jun 2013 16:47:34 +0200 Subject: [PATCH 2/2] Forgot typeof condition --- core/js/octemplate.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/js/octemplate.js b/core/js/octemplate.js index 352a23c4dc..e69c6cc56e 100644 --- a/core/js/octemplate.js +++ b/core/js/octemplate.js @@ -61,7 +61,9 @@ if(typeof this.options.escapeFunction === 'function') { for (var key = 0; key < this.vars.length; key++) { - this.vars[key] = self.options.escapeFunction(this.vars[key]); + if(typeof this.vars[key] === 'string') { + this.vars[key] = self.options.escapeFunction(this.vars[key]); + } } }