Is there a way to recurse in a Tiddler Filter?

69 views
Skip to first unread message

Matthew Lauber

unread,
Aug 8, 2015, 9:03:05 PM8/8/15
to TiddlyWiki
Hello all.  I'm trying to implement the following.  The goal being to grab the contents of a field on this tiddler and the tiddlers specified in the "parent" field, then do the same for those parents.  Is this possible?  I'm pretty sure that I can't use a macro for my goal, but I haven't found any filter that would recurse the same way.

\define inherit(field,sort:)
<$list filter={{!!parent}} >
<$macrocall $name="inherit" field=$field$ />
</$list>
{{!!$field$}}
\end

<$list filter=<<inherit test>> >

</$list>

That produces the following:  

Jed Carty

unread,
Aug 8, 2015, 9:46:07 PM8/8/15
to TiddlyWiki
Yes, you can do what you want.

You need two macros. You call one inside the other. I am currently using my tablet on an airplane so I may not be able to give a good example, but try this:

\define inner()
<$list filter={{!!parent}}>
<<outer>>
</$list>
\end

\define outer()
<<inner>>

<$view field="""$(Field)$"""/>
\end

<$set name=Field value=bob>
<$list filter={{!!parent}}>
<<outer>>
</$list>
</$set>

Where you replace bob with your field name, you can almost certainly make it more compact and wrap it in another macro so you can call it like in your code. Editing this on my tablet is a pain so I am writing this blind and only did one very simple test. Hopefully this is enough so you can modify it to do what you want.

Matthew Lauber

unread,
Aug 10, 2015, 8:14:44 AM8/10/15
to TiddlyWiki
Unfortunately, that's not quite what I wanted to do.  I want to the field as a List Field, and do some arbitrary thing for each element in it.  Therefore, I need to evaluate the macro (including any transclusions) before returning it to the filter= param.  If I call a macro as the filter param, it doesn't seem to resolve any widgets, giving me the output I posted on the bottom of my initial topic.  Further reading has seemed to indicate that wikiText (including widgets) is not evaluated during macro evaluation.  Which means that the filter doesn't receive a list of Tiddlers, but rather a string of wikiText, which it doesn't know how to parse.  At this point, I'm pretty sure what I'm trying to do isn't quite possible, though I'd be happy to be proven wrong.  
Reply all
Reply to author
Forward
0 new messages