I'm trying to create a macro that will format links based on an input string. The label for the link, as well as its target, may or may not be different from the input string itself.
This is my current attempt at such a macro:
\define current_assign(name, target)
<$list filter="[tag[info_assignment]name[$name$]sort[begin]last[]get[$target$]]">
<$list filter="[<currentTiddler>listed[redirect]]" emptyMessage="<<currentTiddler>>" variable="moose">
<$link to=<<moose>> >
<$macrocall $name="get_clean" input=<<currentTiddler>>/>
</$link>
</$list>
</$list>
\end
\define get_clean(input)
{{Dict_Clean!!$input$}}
\end
Works fine if I want to redirect the link and apply a new label, but if I don't want to do one of those, or neither, this solution doesn't work.
I figured that the redirection problem was due to emptyMessage containing only <<currentTiddler>>, so I tried changing the second list widget to a set widget, as follows:
\define current_assign(name, target)
<$list filter="[tag[info_assignment]name[$name$]sort[begin]last[]get[$target$]]">
<$set name="moose" filter="[<currentTiddler>listed[redirect]]" emptyValue="<<currentTiddler>>">
<$link to=<<moose>> >
<$macrocall $name="get_clean" input=<<currentTiddler>>/>
</$link>
</$set>
</$list>
\end
Here's what's strange about this. If the tiddler fetched by listed[redirect] has a space in it, the <$list> widget uses it just fine, but the <$set> widget adds double square brackets around the title. I've been unable to find a reliable way to strip the double brackets, and it makes the process of applying a label to a link impossible.
I've tried using Tobias's setvars widget, same results as the set widget.
If anyone knows of some way to fix this, please let me know!