From 801c8e4c4837b9dd5a8fdb1c7b5beecb33170db9 Mon Sep 17 00:00:00 2001 From: Uma Date: Thu, 25 Dec 2014 12:50:07 +0530 Subject: [PATCH] issue #6 Fix for modifier plugin name and variable name is same and they conflict To avoid conflicts do not use regular function execute which evals the code with with statement. Create a new function which calls function by object. Reference: https://github.com/umakantp/jsmart/issues/6 https://code.google.com/p/jsmart/issues/detail?id=21 --- jsmart.js | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/jsmart.js b/jsmart.js index d5b59e3..f3adb9d 100644 --- a/jsmart.js +++ b/jsmart.js @@ -215,6 +215,23 @@ return code; } + /** + * Execute function when we have a object. + * + * @param object obj Object of the function to be called. + * @param array args Arguments to pass to a function. + * + * @return + * @throws Error If function obj does not exists. + */ + function executeByFuncObject(obj, args) { + try { + return obj.apply(this, args); + } catch (e) { + throw new Error(e.message + ' in \n' + code); + } + } + function assignVar(nm, val, data) { if (nm.match(/\[\]$/)) //ar[] = @@ -2089,17 +2106,24 @@ jSmart.prototype.registerPlugin( 'function', '__func', - function(params, data) - { - var paramNames = []; - var paramValues = {}; - for(var i=0; i