> I'd need a parser function like #if from mediawiki to add some field
> only on condition a parameter was given. Probably that should be done
> using javascript (inline javascript plugin).
> Is there a way to not only automaticaly assume $1 $2 $3
> but some:
>
> <<tiddler [[infobox]] with:$2="baz" $1="bar" $5="foo">>
The substitution mechanism provided by the <<tiddler ... with: ...>>
macro, while very handy for many purposes, does not really provide
support for conditional handling, named parameters, or other
'advanced' use-cases.
Fortunately, as you've noted, InlineJavascriptPlugin can be used very
effectively to dynamically-generate wiki-formatted content using fully
programmable logic and data... and it can include a bit of code that
'unpacks' the $1 through $9 params and convert them into an
associative array of name/value pairs, like this:
<script>
var args={};
if ('$1'!='$'+'1') { var t='$1'.split('='); args[t.shift()]=t.join
('='); }
if ('$2'!='$'+'2') { var t='$2'.split('='); args[t.shift()]=t.join
('='); }
if ('$3'!='$'+'3') { var t='$3'.split('='); args[t.shift()]=t.join
('='); }
if ('$4'!='$'+'4') { var t='$4'.split('='); args[t.shift()]=t.join
('='); }
if ('$5'!='$'+'5') { var t='$5'.split('='); args[t.shift()]=t.join
('='); }
if ('$6'!='$'+'6') { var t='$6'.split('='); args[t.shift()]=t.join
('='); }
if ('$7'!='$'+'7') { var t='$7'.split('='); args[t.shift()]=t.join
('='); }
if ('$8'!='$'+'8') { var t='$8'.split('='); args[t.shift()]=t.join
('='); }
if ('$9'!='$'+'9') { var t='$9'.split('='); args[t.shift()]=t.join
('='); }
// now you can do something with the args[]...
var out='';
if (args['debug']) for (var arg in args) out+=arg+' is: "'+args[arg]
+'"\n';
return out;
</script>
If you put this script in [[SomeTiddler]] and then invoke it from
another tiddler, like this:
<<tiddler SomeTiddler with: foo=bar "baz=mumble frotz" gronk
debug=true>>
You will get output like this:
foo is: "bar"
baz is: "mumble frotz"
gronk is: ""
debug is: "true"
Of course, this is just an example. For your purposes, once you have
easy reference to the name/value pairs, you can use whatever
conditional logic you need to generate the desired output string based
on the values passed in.