-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Introduce let filter run prefix for assigning a filter run result to a variable #8972
base: master
Are you sure you want to change the base?
Conversation
Confirmed: Jermolene has already signed the Contributor License Agreement (see contributing.md) |
✅ Deploy Preview for tiddlywiki-previews ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
I am not overly happy with special handling of May be
IMO I did play with: I could imagine an |
The RSOD only triggers if the input is typed. Not if copy / pasted. |
Not needed because the input to the filter run is available
Extend let filter run prefix to store list of results, and add varlist operator for accessing variables as a list. We already had partial support for variables returning a list of values in order for functions to work, now we extend it so that any variable can be used to store a list We should extend the set widget so that it returns a result list that can be accessed with the varlist operator
Thanks @pmario that should be fixed now.
I've extended the implementation of variables so that they can store a result list as well as a single value. This allows the let filter run prefix to assign the entire results to the variable. The new |
Terrible name. Annoyingly, we can't overload the existing let or set widgets.
This PR introduces a new filter run prefix
:let
that assigns the result of the filter run to a variable that is made available for the remaining filter runs of the filter expression.It solves the problem that otherwise it is impossible to compute values for filter operator parameters; parameters can only be a literal string, text reference or variable reference. The
:let
filter run prefix provides a solution:Note that within the filter run the
all[]
operator (with a blank parameter) will return all the input titles received by the:let
filter run prefix, not the input titles received by the overall filter expression. This permits the results of other filter run prefixes to be assigned to a variable. For following example first sorts all the input tiddlers by length, and then uses the length of the shortest title as the second index of a JSON lookup:This PR also introduces the ability for variables to contain list of results, not just single strings. They can be assigned with the
:let
filter run prefix, or the new<$letlist>
widget. The full list of values can be retrieved with the newvarlist
operator; in other contexts only the first item in the list is used as the variable value.Note that this PR is intended to be a more generic replacement for the experiment
:apply
filter operator that is currently part of #8702 - see the code and the docs