Tagscript

UnionStatementParser

Return the first branch when any one of several expressions is true.

any takes a list of expressions and returns the first branch if at least one of them is true.

For template authors

Syntax

{any(expression|expression|...):true message|false message}

Split the expressions with pipes, and split the two branches with a pipe as well. The operators are the same ones if uses.

Examples

{any({args}==hi|{args}==hello|{args}==hey):Hello!|How rude.}
# when args is "hello"
Hello!
# when args is "what's up"
How rude.

Aliases

any, or, union

For developers

Register the parser

import { Interpreter, UnionStatementParser } from 'tagscript';
const ts = new Interpreter(new UnionStatementParser());

Behaviour

Both the parameter and the payload are required.

Every expression is evaluated, then the results are OR-ed together. There is no short circuit, so an expression cannot rely on an earlier one failing.

API reference

UnionStatementParser

Last updated on

On this page

Edit on Github