# if

    .if condition:{Boolean?} body:{Lambda} -> Any

Content copied to clipboard

Performs a conditional evaluation of content, including the evaluation of body only if the condition is met. The expression is not evaluated if the condition is false.

Conditional statements return the evaluation of the body if the condition is met, nothing otherwise, and can be used for different purposes, both for layout and for logic.

    # Shopping list

    .var {needapples} {yes}

    .if {.needapples}
        I need apples.

Content copied to clipboard

    .row
        A

        .if {yes}
            B

        C

Content copied to clipboard

    .function {safedivide}
        numerator denominator:
        .if {.denominator::equals {0}}
            0
        .ifnot {.denominator::equals {0}}
            .numerator::divide by:{.denominator}

Content copied to clipboard

    .function {greet}
        name?:
        .if {.name}
            Hi, .name!

Content copied to clipboard

#### Return

the evaluation of body if condition is `true`, nothing otherwise

#### Parameters

condition

whether the content should be evaluated. If `none`, it is treated as `false`

body

- Likely a body argument

content to evaluate if condition is verified. Accepts 0 parameters.

#### Wiki page

conditional-statements