이 문서는 https://tiddlywiki.com/languages/ko-KR/에서 티들리위키의 정적 HTML 표현의 일부입니다

Conditional Operators

2023년 7월 11일 오전 8:23

Introduced in v5.1.20 The conditional filter operators allow if-then-else logic to be expressed within filters.

The foundation is the convention that an empty list can be used to represent the Boolean value false and a list with at one (or more) entries to represent true.

The conditional operators are:

  • then Operator replaces any input values with a constant string. For example:
    • [[HelloThere]is[missing]then[FOO]]evaluates to(empty)
    • [[Missing Tiddler]is[missing]then[FOO]]evaluates toFOO
  • else Operator if the title list is empty then returns a constant string, otherwise returns the original title list
    • [[HelloThere]is[tiddler]else[BAR]]evaluates toHelloThere
    • [[Missing Tiddler]is[tiddler]else[BAR]]evaluates toBAR

These operators can be combined. For example:

[[New Tiddler]is[missing]then[I am missing]else[No I am not missing]]

The else operator can be used to apply a defaults for missing values. In this example, we take advantage of the fact that the get operator returns an empty list if the field or tiddler does not exist:

[[HelloThere]get[custom-field]else[default-value]]

Filter Run Prefixes

The :then and :else named filter run prefixes serve a similar purpose as the conditional operators.

Also see: Named Filter Run Prefix