mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 12:07:19 +00:00
Add subfilter operator examples and mention when it is a constructor (#6155)
This commit is contained in:
parent
d9eb5499a3
commit
daa9a8ae45
@ -1,8 +1,30 @@
|
||||
created: 20181031175129475
|
||||
modified: 20181031175129475
|
||||
modified: 20211030223407188
|
||||
tags: [[subfilter Operator]] [[Operator Examples]]
|
||||
title: subfilter Operator (Examples)
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.operator-example 1 "[subfilter[one two three]addsuffix[!]]">>
|
||||
<<.operator-example 2 "[subfilter{$:/StoryList!!list}]">>
|
||||
\define recent-mods() [has[modified]!sort[modified]limit[5]]
|
||||
\define display-variable(name)
|
||||
''<$text text=<<__name__>>/>'': <code><$text text={{{ [<__name__>getvariable[]] }}}/></code>
|
||||
\end
|
||||
|
||||
Literal filter operands can be used, but such cases are better rewritten without using <<.op subfilter>>:
|
||||
<<.operator-example 1 "[subfilter[one two three]addsuffix[!]]" "same as `one two three +[addsuffix[!]]`">>
|
||||
|
||||
The <<.op subfilter>> operator can be used to dynamically define parts of a [[filter run|Filter Run]]. This is useful for sharing a common pieces of a filter across multiple filters.
|
||||
|
||||
For example, this variable:
|
||||
|
||||
* <<display-variable recent-mods>>
|
||||
|
||||
can be used in one filter like this:
|
||||
|
||||
<<.operator-example 2 "[tag[Filter Operators]subfilter<recent-mods>addsuffix[!]]" "same as `[tag[Filter Operators]has[modified]!sort[modified]limit[5]addsuffix[!]]`">>
|
||||
|
||||
and in another similar filter like this:
|
||||
<<.operator-example 3 "[tag[ActionWidgets]subfilter<recent-mods>addprefix[!]]">>
|
||||
|
||||
Variables are not the only way to define dynamic subfilters. [[Text references|TextReference]] can be used to load a subfilter from a tiddler field (see also [[Filter Parameter]]):
|
||||
<<.operator-example 4 "[subfilter{$:/StoryList!!list}limit[5]]">>
|
||||
<<.operator-example 5 "[subfilter{$:/StoryList!!list}subfilter<recent-mods>]">>
|
||||
|
@ -1,6 +1,6 @@
|
||||
caption: subfilter
|
||||
created: 20181031175129475
|
||||
modified: 20181031175129475
|
||||
modified: 20211030223407188
|
||||
op-input: a [[selection of titles|Title Selection]] passed as input to the subfilter
|
||||
op-neg-input: a [[selection of titles|Title Selection]] passed as input to the subfilter
|
||||
op-neg-output: those input titles that are <<.em not>> returned from the subfilter <<.place S>>
|
||||
@ -12,7 +12,7 @@ tags: [[Filter Operators]] [[Field Operators]] [[Selection Constructors]] [[Nega
|
||||
title: subfilter Operator
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
<<.from-version "5.1.18">> Note that the subfilter operator was introduced in version 5.1.18 and is not available in earlier versions.
|
||||
<<.from-version "5.1.18">> Note that the <<.op subfilter>> operator was introduced in version 5.1.18 and is not available in earlier versions.
|
||||
|
||||
<<.tip " Literal filter operands cannot contain square brackets but you can work around the issue by using a variable:">>
|
||||
|
||||
@ -24,4 +24,6 @@ type: text/vnd.tiddlywiki
|
||||
|
||||
<<.tip "Compare with the similar [[filter|filter Operator]] operator which runs a subfilter against each title, returning those titles that return a non-empty list (and discards the results of the subfilter)">>
|
||||
|
||||
The <<.op subfilter>> operator will act as a [[constructor|Selection Constructors]] whenever the filter defined by its operand is a [[constructor|Selection Constructors]]. Otherwise, it will act as a [[modifier|Selection Constructors]].
|
||||
|
||||
<<.operator-examples "subfilter">>
|
||||
|
Loading…
Reference in New Issue
Block a user