This is a method that has been added to the standard String object. It is used to parse a space-separated string of name:value parameters that are usually given to a TiddlyWiki macro. It is used by calling it on a string like so:
str.parseParams(args....);

It takes upto 5 arguments (defaultName,defaultValue,allowEval,noNames,cascadeDefaults).
  • defaultName - used as the key of key value pair if lone words used.
  • defaultValue - used as the value of key value pair if lone words used.
  • allowEval - if 'true' allows you to use evaluated parameters, evaluated parameters are not allowed in TiddlySpace.
  • noNames - if true then string is just split on the spaces.
  • cascadeDefaults - if 'true' takes the first lone word or first key as the key for all subsequent lone words until another key:valur pair is parsed. At which point that because the key for any lone words that follow.

The result is an array of objects:
* result[0] = object with a member for each parameter name/key, value of that member being an array of values
  • result[1..n] = one object for each parameter, with 'name' and 'value' members

Examples

Simplest, for string only containing key:value pairs
str = "foo:bar";
str.parseParams(null, null, false, false, false);
returns
result[0] = { foo=["bar"] }
result[1] = { name="foo", value="bar" }

Containing a mix
str = "test foo:bar";
str.parseParams("xyz", null, false, false, false);
returns
result[0] = { xyz="test", foo=["bar"] }
result[1] = { name="xyz", value="test" }
result[2] = { name="foo", value="bar" }
bag
tiddlywikidev_public
created
Wed, 09 Mar 2011 12:22:03 GMT
creator
colmbritton
modified
Wed, 09 Mar 2011 12:22:03 GMT
modifier
colmbritton
tags
method
tiddlywiki