neutralts::bif

Module parse_bif_eval

Source
Expand description

§{:eval; … :}

Output code if the result of eval is not empty (non-zero length).

{:eval; code >> code :}

{:eval; {:;varname:} >>
    shown if varname is not empty
:}

A variable is set with the result of the evaluation:

{:eval; {:;varname:} >>
    ...
    {:;__eval__:}
    ...
:}

§Modifiers:

{:!eval; ... :}
{:+eval; ... :}
{:^eval; ... :}

For more details about the “+” modifier see “modifiers”.

§Modifier: ! (not)

{:!eval; {:;varname:} >>
    shown if varname is empty
:}

§No flags

§Usage

Eval evaluates code versus filled which evaluates a variable:

    {:filled; varname >>
        ...
    :}

    {:eval; {:code: {:;varname:} :} >>
        ...
    :}

Sometimes it is necessary to evaluate code:

<li>{:snippet; snippet-name :}</li>

The output of the above if “snippet-name” is empty will be:

<li></li>

To prevent this from happening, it can be done:

{:eval; {:snippet; snippet-name :} >>
    <li>{:;__eval__:}</li>
:}

And in this case the “li” will only be displayed if “snippet-name” is not empty.

The following are equivalent, but the first does not require re-evaluation of the snippet and may be clearer as to what is intended:

{:eval; {:snippet; snippet-name :} >>
    <li>{:;__eval__:}</li>
:}
{:eval; {:snippet; snippet-name :} >>
    <li>{:snippet; snippet-name :}</li>
:}

This is also possible

{:eval; {:;varname1:}{:;varname2:} >>
    ...
    {:;__eval__:}
    ...
:}
{:eval;
    {:code;
        ... a lot of code here ...
    :}
    >>
    ...
    {:;__eval__:}
    ...
:}

Can also be used to prevent output, in the following example, we want the include to show a possible output:

{:+eval; {:include; file :} >> :}

For more details about the “+” modifier see “modifiers”.