TiddlyWiki5 icon indicating copy to clipboard operation
TiddlyWiki5 copied to clipboard

generalize the tree macro to support any field

Open andjar opened this issue 10 months ago • 1 comments

The tree macro is modified to support a field parameter, defaulting to title for backward compatibility. As suggested in #8129, a tiddler with fields

title: /A/B/C
path1: /B/A/C
path2: /C/B/A

will be placed at different locations in the tree using the calls

<<tree prefix:"/">> // Defaults to title
<<tree prefix:"/" field:"path1">>
<<tree prefix:"/" field:"path2">>

The performance seems suboptimal compared to the original implementation, possibly due to nested looping over all tiddlers in tree_node:

<$list filter="[all[shadows+tiddlers]get<__field__>prefix<__prefix__>removeprefix<__prefix__>splitbefore<__separator__>sort[]!suffix<__separator__>]" variable="chunk">
<$list filter="[all[shadows+tiddlers]has<__field__>sort[]] :filter[get<__field__>removeprefix<__prefix__>match<chunk>]" variable="title">
<$macrocall $name="leaf-node" prefix=<<__prefix__>> chunk=<<chunk>> title=<<title>> separator=<<__separator__>>/>
</$list>
</$list>

andjar avatar Apr 05 '24 20:04 andjar

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
tiddlywiki5 ✅ Ready (Inspect) Visit Preview Apr 17, 2024 8:33pm

vercel[bot] avatar Apr 05 '24 20:04 vercel[bot]