kopia lustrzana https://github.com/miklobit/TiddlyWiki5
Fixed problem with ArgParser returning non-string argument names
rodzic
3560703078
commit
4c19c76461
|
@ -26,6 +26,8 @@ Options and their defaults are:
|
||||||
|
|
||||||
var ArgParser = function(argString,options) {
|
var ArgParser = function(argString,options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
var defaultName = options.defaultName,
|
||||||
|
defaultValue = options.defaultValue;
|
||||||
var parseToken = function(match,p) {
|
var parseToken = function(match,p) {
|
||||||
var n;
|
var n;
|
||||||
if(match[p]) { // Double quoted
|
if(match[p]) { // Double quoted
|
||||||
|
@ -62,16 +64,21 @@ var ArgParser = function(argString,options) {
|
||||||
this.byPos.push({n:"", v:n});
|
this.byPos.push({n:"", v:n});
|
||||||
} else {
|
} else {
|
||||||
v = parseToken(match,8);
|
v = parseToken(match,8);
|
||||||
if(v === undefined && options.defaultName) {
|
if(v === undefined && defaultName) {
|
||||||
v = n;
|
v = n;
|
||||||
n = options.defaultName;
|
n = defaultName;
|
||||||
} else if(v === undefined && options.defaultValue) {
|
} else if(v === undefined && defaultValue) {
|
||||||
v = options.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});
|
this.byPos.push({n:n, v:v});
|
||||||
if(options.cascadeDefaults) {
|
if(options.cascadeDefaults) {
|
||||||
options.defaultName = n;
|
defaultName = n;
|
||||||
options.defaultValue = v;
|
defaultValue = v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue