1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-16 10:29:54 +00:00

Docs: reference documentation for :cascade filter run prefix (#6294)

* docs: formal documentation for :cascade filter run prefix

* fix: typos

* fix: typos
This commit is contained in:
Saq Imtiaz 2021-11-30 16:07:10 +01:00 committed by GitHub
parent 75aabcce64
commit 485730483b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,22 @@
created: 20211130114857532
modified: 20211130132353406
tags: [[Filter Run Prefix Examples]] [[Filter Syntax]] [[Cascade Filter Run Prefix]]
title: Cascade Filter Run Prefix (Examples)
type: text/vnd.tiddlywiki
The <<.op ":cascade">> filter run prefix is used by the ~TiddlyWiki core to choose the colour for each tiddler as used in the tag pill generated by the tag macro.
`:cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerColourFilter]get[text]]`
The filter expression inside the above <<.op :cascade>> filter run returns a list of filters from the text fields of tiddlers tagged <<tag $:/tags/TiddlerColourFilter>> as shown below:
<ul>
<$list filter="[all[shadows+tiddlers]tag[$:/tags/TiddlerColourFilter]get[text]]">
<li><pre><$text text=<<currentTiddler>>/></pre></li>
</$list>
</ul>
For each input title, each of these filters is now applied to in turn until the first filter that returns a non-empty list. The first result from this non-empty list replaces that input title and is used as the colour for that tiddler.
<<.operator-example 1 """[all[shadows+tiddlers]] :cascade[all[shadows+tiddlers]tag[$:/tags/TiddlerColourFilter]get[text]] +[!is[blank]limit[10]]""">>

View File

@ -0,0 +1,20 @@
created: 20211130114043280
modified: 20211130121544118
tags: [[Filter Syntax]] [[Filter Run Prefix]]
title: Cascade Filter Run Prefix
type: text/vnd.tiddlywiki
<<.from-version "5.2.1">>
|''purpose'' |modify input titles by evaluating in turn a list of filters - as returned by the filter expression for this run - for each input title. |
|''input'' |all titles from previous filter runs |
|''output''|the input titles as modified by the filters returned by this filter run |
The filter expression for this filter run is evaluated to return a list of filters. Each input title is then evaluated against each of the filters in turn, and the input title is replaced with the first result of the first filter that returns a non-empty list. If none of the filters return a result for an input title, it is replaced with an empty string.
The following variables are available within the filter run:
* <<.var currentTiddler>> - the input title
* <<.var ..currentTiddler>> - the value of the variable `currentTiddler` outside the filter run.
[[Examples|Cascade Filter Run Prefix (Examples)]]