Hi everyone,
Suppose we have a task called [[Meeting with friends]]. This task can be split into several subtasks (children), and each subtask can in turn be split into further subtasks.
When a subtask is created, its parent field is set to the title of its parent task. Given this structure, how can I recursively traverse all subtasks of a task using TiddlyWiki’s function pragma?
I’ve already found a way to recursively traverse all child tiddlers using a procedure, and it works correctly. However, it doesn’t feel very elegant to me. Ideally, I’d like to achieve the same result using a function pragma instead.
Does anyone have suggestions or examples for doing this with function?
Here is the procedure-based approach I’m currently using to traverse all child tiddlers:
\procedure travel-recurse(root)
\function get-formatted-title() [<currentTiddler>format:titlelist[]]
<$list filter="[parent<root>]">
<<get-formatted-title>>
<$transclude $variable="travel-recurse" root=<<currentTiddler>>/>
</$list>
\end
<$wikify name="tasks-list" text="""<$transclude $variable="travel-recurse" root="Meeting with friends"/>""">
<ul>
<$list filter="[enlist<tasks-list>]">
<li>
<$link to=<<currentTiddler>>>
<<get-task-caption>>
</$link>
</li>
</$list>
</ul>
</$wikify>
I’ve also created a complete demo site for this question, which you can test directly at
https://com.tiddlyhost.com/.