Hello r.g. The tagging operator <https://tiddlywiki.com/#tagging%20Operator> seems to be just made for you! Since you just need to have a list of 1, you limit the filter's output.
So you might try this in your *Sub Tiddlers* template: <$list filter="[all[current]tagging[]limit[1]]"> <<t>> </$list> If the list is empty, meaning there are no tiddlers tagged with the title of the current tiddler, the <<t>> macro wont show up. Cheers. On Friday, April 5, 2019 at 1:56:03 AM UTC+7, registrierungs genervter wrote: > > I would like to add a TOC of Sub Tiddlers (Tiddlers tagged with this > Tiddler) at the end of each tiddler. > > I would like to do this automatically, but only if there are Sub Tiddlers. > > Currently im doing it manually: > > I have defined a macro *t* in a Tiddler tagged with '$:/tags/Macro': > > \whitespace trim > \define t() > <hr> > Sub-Tiddlers: > <div class="tc-table-of-contents"> > <$macrocall $name="toc-selective-expandable" tag=<<currentTiddler>> > sort="!tag[Ignore in TOCs]sort[title]"/> > </div> > \end > > And then i add <<t>> at the end of each Tiddler which has Sub Tiddlers. > > I would like to do this by creating a Template Tiddler *Sub Tiddlers*, > which contains a call to the <<t>> macro, and adding that Template > Tiddler to the list field of $:/tags/ViewTemplate. > > But this way the *hr* and the text 'Sub-Tiddlers:' always gets included, > even if the result of the call to toc-selective-expandable is empty. > Which i dont want. > > So either > > > - ideally i would like to include *Sub Tiddler* only if there are Sub > Tiddlers. But i have no idea how to achieve this. > - or i convert <<t>> to a javascript macro (because, if i am not > wrong, if/else is not possible in normal macros like the above one). > Then my problem for now is, how would i call the > toc-selective-expandable macro from within Javascript and how would i > figure out that its result is empty? > Or, where in the code base <https://github.com/Jermolene/TiddlyWiki5> is > this macro defined? > > Any hints appreciated. > -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscr...@googlegroups.com. To post to this group, send email to tiddlywiki@googlegroups.com. Visit this group at https://groups.google.com/group/tiddlywiki. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/360ec230-605c-49f3-aafc-952c7f34ac73%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.