On this page:


<txp:evaluate />

The evaluate tag can be used as either a single or container tag. When used as a single tag, it will evaluate the expression given by the query attribute and output its value. When used as a container tag, it will first check whether the query expression (if set) produces an empty result and output nothing in this case. Otherwise, it will process the contained tags optionally filtered by the test attribute. If all of them produce empty results, nothing will be output. Otherwise, it will return the whole processed content.


Tag will accept the following attributes (case-sensitive):

A numerical, logical or string XPath expression to evaluate.
Values: 2 * 2, string-length("Textpattern") < 10, and so on.
Default: unset.
test="tags list"
The (top-level) tags to test for non-emptiness.
Default: unset (test all tags).


Example 1: Increase the value of a variable

<txp:variable name="counter" value="0" />

    <txp:variable name="counter" value='<txp:evaluate query=''<txp:variable name="counter" /> + 1'' />' />

Other tags used: article, variable.

<txp:evaluate test="linklist">
        <txp:linklist wraptag="ul" break="li" />
<txp:else />
    <p>No links registered yet.</p>

Other tags used: else, linklist.


Version 4.7.0

Tag support added.

See something wrong in this document? Outdated info, a broken link, faulty code example, or whatever? Please open an issue and we’ll investigate.