From c37c58ad39d8d1991065d0b7db561ab116afdd27 Mon Sep 17 00:00:00 2001 From: Miosss Date: Wed, 9 Jul 2014 14:57:08 +0200 Subject: [PATCH 1/2] Alternative scale templating. Passing function as template. Allows to choose template mechanism - processing function or original micro templating. --- src/Chart.Core.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 3484ae223..8a1c95bbe 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -402,6 +402,10 @@ //Templating methods //Javascript micro templating by John Resig - source at http://ejohn.org/blog/javascript-micro-templating/ template = helpers.template = function(templateString, valuesObject){ + // If templateString is function rather than string-template - call the function for valuesObject + if(templateString instanceof Function) + return templateString(valuesObject); + var cache = {}; function tmpl(str, data){ // Figure out if we're getting a template, or if we need to @@ -1886,4 +1890,4 @@ return Chart; }; -}).call(this); \ No newline at end of file +}).call(this); From d193951dc5871aac230f3f778ec3c5c0cf1d47af Mon Sep 17 00:00:00 2001 From: Miosss Date: Thu, 10 Jul 2014 13:13:38 +0200 Subject: [PATCH 2/2] Alternative templating, cleanup. Just added brackets. --- src/Chart.Core.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Chart.Core.js b/src/Chart.Core.js index 8a1c95bbe..005c258c1 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -404,7 +404,9 @@ template = helpers.template = function(templateString, valuesObject){ // If templateString is function rather than string-template - call the function for valuesObject if(templateString instanceof Function) + { return templateString(valuesObject); + } var cache = {}; function tmpl(str, data){