This is a stripped-down version of a single section of Grok TiddlyWiki, optimized for fast loading and readability by search engines. Some features are missing.

For the full Grok TiddlyWiki experience, please visit the wiki version of this page.

Ex:BasicLinksList/answer

18th April 2021 at 9:25am

My tiddler now looks like this:

\define linkDisplay(title, filterFragment)
$title$:

<ul>
<$list filter="[all[current]$filterFragment$]">
  <li><$link /></li>
</$list>
</ul>
\end

<<linkDisplay "Links" "links[]">>
<<linkDisplay "Backlinks" "backlinks[]">>

Let's talk about filterFragment for a moment. The way shown above is the simplest way to handle it, and TiddlyWiki's core does this in a number of macros, but if we didn't want to use text substitution, or we wanted to be able to reuse this macro in places where we didn't always want just the current tiddler, we could also make the entire filter the parameter to the macro (we'll call it filterString) and use parameter substitution instead:

\define linkDisplay(title, filterString)
[…]
<$list filter=<<__filterString__>>>
[…]

Another option would be to use subfilter. This filter operator takes an argument which is itself a filter run, and passes the current data into that run. Here's how we could do that:

\define linkDisplay(title, filterFragment)
$title$:

<ul>
<$list filter="[all[current]subfilter<__filterFragment__>]">
  <li><$link /></li>
</$list>
</ul>
\end

<<linkDisplay "Links" "[links[]]">>
<<linkDisplay "Backlinks" "[backlinks[]]">>

Two things to note here:

  • Previously, the filterFragment parameter was just a single filter step. Now it has to be a complete filter run.
  • Using macro parameter substitution with <<__param__>> is valid inside a filter, so long as you use single angle brackets.

Go to question: Ex:BasicLinksList