mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-09-19 18:59:42 +00:00
72 lines
2.5 KiB
Plaintext
72 lines
2.5 KiB
Plaintext
|
created: 20210618133745003
|
||
|
from-version: 5.3.0
|
||
|
modified: 20230506172920710
|
||
|
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: [[Filter Run Prefix]] [[Filter Syntax]]
|
||
|
title: Then Filter Run Prefix
|
||
|
type: text/vnd.tiddlywiki
|
||
|
|
||
|
\define .op-row()
|
||
|
<$macrocall $name=".if"
|
||
|
cond="""$(op-body)$"""
|
||
|
then="""<tr><th align="left">$(op-head)$</th><td><<.op-place>>$(op-body)$</td></tr>"""
|
||
|
else=""/>
|
||
|
\end
|
||
|
|
||
|
<$list filter="[all[current]has[from-version]]" variable="listItem">
|
||
|
<$macrocall $name=".from-version" version={{!!from-version}}/>
|
||
|
</$list>
|
||
|
<$let op-head="" op-body="" op-name="">
|
||
|
<table class="doc-table">
|
||
|
<!-- purpose -->
|
||
|
<$let op-head="purpose" op-body={{!!rp-purpose}}>
|
||
|
<<.op-row>>
|
||
|
</$let>
|
||
|
<!-- input -->
|
||
|
<$let op-head="[[input|Filter Expression]]" op-body={{!!rp-input}}>
|
||
|
<<.op-row>>
|
||
|
</$let>
|
||
|
<!-- suffix -->
|
||
|
<$let op-head="suffix" op-body={{!!rp-suffix}} op-name={{!!rp-suffix-name}}>
|
||
|
<<.op-row>>
|
||
|
</$let>
|
||
|
<!-- output -->
|
||
|
<$let op-head="output" op-body={{!!rp-output}}>
|
||
|
<<.op-row>>
|
||
|
</$let>
|
||
|
</table>
|
||
|
</$let>
|
||
|
|
||
|
<$railroad text="""
|
||
|
\start none
|
||
|
\end none
|
||
|
":then"
|
||
|
[[run|"Filter Run"]]
|
||
|
"""/>
|
||
|
|
||
|
!Introduction
|
||
|
|
||
|
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]]">>|
|
||
|
|
||
|
|
||
|
! [[Examples|Then Filter Run Prefix (Examples)]]
|
||
|
|