From 4c19c764612c1c4a801dda56dc0d433721e9e373 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Sat, 7 Jan 2012 20:07:54 +0000 Subject: [PATCH] Fixed problem with ArgParser returning non-string argument names --- js/ArgParser.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/js/ArgParser.js b/js/ArgParser.js index bf4af9919..cfa4052cd 100755 --- a/js/ArgParser.js +++ b/js/ArgParser.js @@ -26,6 +26,8 @@ Options and their defaults are: var ArgParser = function(argString,options) { options = options || {}; + var defaultName = options.defaultName, + defaultValue = options.defaultValue; var parseToken = function(match,p) { var n; if(match[p]) { // Double quoted @@ -62,16 +64,21 @@ var ArgParser = function(argString,options) { this.byPos.push({n:"", v:n}); } else { v = parseToken(match,8); - if(v === undefined && options.defaultName) { + if(v === undefined && defaultName) { v = n; - n = options.defaultName; - } else if(v === undefined && options.defaultValue) { - v = options.defaultValue; + n = defaultName; + } else if(v === undefined && defaultValue) { + v = defaultValue; + } + if(n.evaluated === true) { + n = "{{" + n.string + "}}"; + } else if (typeof n === "object" && "string" in n) { + n = n.string; } this.byPos.push({n:n, v:v}); if(options.cascadeDefaults) { - options.defaultName = n; - options.defaultValue = v; + defaultName = n; + defaultValue = v; } } }