Yelp

(The Help System)

mal.if.test

Parameters

$node

The element to check the condition for.

$test

The test expression.

This template evaluates the test expression $test, which is taken automatically from the test or if:test attribute of $node. It splits the expression on commas into subexpressions, then splits each subexpression on spaces into tokens. A token is taken to be true if it's in one of the space-separated lists from mal.if.target, mal.if.platform, mal.if.features, or mal.if.custom. If the token starts with an exclamation point, the exclamation point is stripped and the resulting truth value is negated.

A subexpression is true if all its tokens is true. The full test expression is true if any subexpression is true. If the test expression is true, the literal string 'true' is returned. If the test expression is false, the empty string is returned.

This template can handle "maybe" values: tokens that may or may not be true, and whose truth values are deferred to post-transform time. A token is maybe if it appears in the space-separated list mal.if.maybe. If a subexpression contains a maybe value and does not contain any false tokens, its truth value is a special string constructed from the maybe tokens and starting with the string if__. If any subexpressions are maybe and none of the subexpressions are false, the return value is a space-separated list of the maybe strings.

Maybe tokens usually must be handled specifically by the importing stylesheet. It's usually not sufficient to just add a token to mal.if.maybe. This template will handle any maybe token, but it does not handle the actual logic of dynamically showing or hiding content based on those tokens.