Introduction
Since the release of the first beta at 15th December 2013 and the first version 5.1.0 of TiddlyWiki5 at 20th September 2014 we have gone a long way.
These examples should show the difference between the current macro implementation designed back then and upcoming features procedures and functions.
Dynamic URL Example
(All of the code snippets in the first post have issues because of the current implementation details.)
A very common usecase is the dynamic creation of URLs, where our users always have problems and the naive implementation shows several technical problems
Code with Current Macro Definition
This macro definition uses the simple text substitution mechanism.
\define dynURL(protocol:"https", host, path, tiddler) $protocol$://$host$/$path$#$tiddler$
Eg: create a dynamic link to the HelloThere tiddler at tiddlywiki.com
<<dynURL host:"tiddlywiki.com" tiddler:"HelloThere">> -> Works OK
First Technical Problem
Now let’s say we want to create a list of clickable URLs for tiddlers tagged HelloThere
<$list filter="[tag[HelloThere]]" />
gives us the list.
The intuitive code for the dynamic URL list would look like this:
<$list filter="[tag[HelloThere]]" variable="tiddler">
<$macrocall $name="dynURL" host="tiddlywiki.com" tiddler=<<tiddler>> /><br>
</$list>
BUT … as you can see it breaks down because of the spaces in the titles
First attempt … to fix that problem we introduce triple double quotes
The macro definition would need to look like this
\define dynURL(protocol:"https", host, path, tiddler) """$protocol$"""://"""$host$"""/"""$path$"""#"""$tiddler$"""
BUT that does NOT work.
Second attempt use <<__var__>>
for macro parameters
\define dynURL(protocol:"https", host, path, tiddler) <<__protocol__>>://<<__host__>><<__path__>>#<<__tiddler__>>
BUT that does NOT work either
Third attempt … use the transcluded filter trick {{{ [<__var1__>][<__var2__>] +[join[]] }}}
\define dynURL(protocol:"https", host, path, tiddler) {{{ [<__protocol__>][[://]][<__host__>][<__path__>][[#]][<__tiddler__>] +[join[]] }}}
Looks promising BUT does not work
WTF … It should be simple … Go to the forum and tell them they are @"!§$%&