Yes. It isn’t as easy but it can be done. The $parseTreeNodes
attribute on the parameters widget gives access to the children array and the jsonindexes
and jsonget
operators can be used to get the content:
\widget $link()
\whitespace trim
<!-- Use a parameters widget so we can use `$params` to define a variable
containing all the passed-in parameters -->
<$parameters to=<<currentTiddler>> tiddler="" $params="@params" $parseTreeNodes=@ptn>
<$genesis
$type="$link"
$remappable="no"
$names="[<@params>jsonindexes[]]"
$values="[<@params>jsonindexes[]] :map[<@params>jsonget<currentTiddler>]">
<$list
emptyMessage="<$slot $name=ts-raw><$text text=<<to>>/></$slot>"
filter="[<@ptn>jsonindexes[]] :map[<@ptn>jsonget<currentTiddler>,[text]] :and[regexp[-]split[-]join[ ]]">
<$text text=<<currentTiddler>>/>
</$list>
</$genesis>
</$parameters>
\end
In the above, I use the variable names @ptn
to access the children. If there is a text field containing a dash, then the dashes are replaced with spaces. Otherwise it will fallback to the $slot
content.
#[[A-Link-With-Hyphens]]
#<$link to="A-Link-With-Hyphens"/>
#<$link to="A-Link-With-Hyphens"></$link>
#[[some missing tiddler]]
#HelloThere
#[[link text|HelloThere]]
#<$link to="HelloThere">Some different text</$link>
#<$link/>
#<$link to="HelloThere"/>
#<$link to="HelloThere"></$link>
With the changes, the above (placed in a tiddler named “modified link widget test”) renders like this:
- A Link With Hyphens
- A-Link-With-Hyphens
- A-Link-With-Hyphens
- some missing tiddler
- HelloThere
- link text
- Some different text
- modified link widget test
- HelloThere
- HelloThere
As you can see the dashes in test case 2 and 3 are not handled. More changes would be required.
You can see the above in action using this share site link.