TiddlyWiki5/editions/tw5.com/tiddlers/filters/syntax/then Filter Run Prefix.tid

39 lines
1.7 KiB
Plaintext

created: 20210618133745003
from-version: 5.3.0
modified: 20230710074225410
rp-input: <<.olink all>> tiddler titles
rp-output: the output of this filter run replaces the output of previous runs unless it is an empty list (see below)
rp-purpose: replace any input to this filter run with its output, only evaluating the run when there is any input
search:
tags: [[Named Filter Run Prefix]]
title: Then Filter Run Prefix
type: text/vnd.tiddlywiki
<$railroad text="""
\start none
\end none
":then"
[[run|"Filter Run"]]
"""/>
The <<.op :then>> filter run prefix is used to replace the result of all previous filter runs with its output.
If the result of all previous runs is an empty list, the <<.op :then>> prefixed filter run is not evaluated.
If the output of a <<.op :then>> prefixed filter run is itself an empty list, the result of all previous filter runs is passed through unaltered.
<<.tip "Note that a list with a single empty string item is not an empty list.">>
!! <<.op :then>> run prefix versus the <<.olink then>> operator
The major difference between the <<.op then>> operator and a <<.op :then>> prefixed filter run is that the operator will replace //each item// of the input [[Title List]] with its parameter while <<.op :then>> will replace the //whole input list// with the result of its run.
|doc-op-comparison tc-center|k
| !<<.op :then>> Filter Run Prefix | !<<.op then>> Operator |
|^<<.operator-example m1-1 "[tag[WikiText]] :then[[true]]">>|^<<.operator-example m1-2 "[tag[WikiText]then[true]]">><p>To make them equivalent, additional filter steps may be added:</p> <<.operator-example m1-3 "[tag[WikiText]count[]compare:number:gt[0]then[true]]">>|
[[Then Filter Run Prefix (Examples)]]