-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
generalize the tree macro to support any field #8134
base: master
Are you sure you want to change the base?
Conversation
Make the tree macro accepts custom fields
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
<$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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having 2 lists that iterate over every shadow and every tiddler starting from new, may be the performance bottle neck - as you suggest. So if possible we may be able to "reuse" some results from the first list as input to the second one. -- But I did not have a look at the code at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that the performance must be improved. The challenge, I think, is that we need to (1) find and sort the list of all valid field values (i.e., those with a given prefix) and (2) find all tiddlers with the given field values
One strategy may be to
- Find tiddlers with valid field values
- Join field value and tiddler title with the separator
- Sort the list of field value-tiddler title strings
- Split by the separator and somehow extract the last element (tiddler title)
But that would require a larger re-write of the tree macro
improve backwards compatibility
The tree macro is modified to support a
field
parameter, defaulting to title for backward compatibility. As suggested in #8129, a tiddler with fieldswill be placed at different locations in the tree using the calls
The performance seems suboptimal compared to the original implementation, possibly due to nested looping over all tiddlers in
tree_node
: