Skip to content

Conformance Examples 0.1.0 — Render: parenthesized-logic

grouping-or-first-diverges-from-and-first

With a=false, b=true, c=true: 'a and (b or c)' groups the or first ('b or c' = true), giving 'false and true' = false.

Template

{{ a and (b or c) }}

Context

{
    "a": false,
    "b": true,
    "c": true
}

Output

false

grouping-and-first-diverges-from-or-first

Same context (a=false, b=true, c=true), but grouping the and first instead: '(a and b) or c' gives '(false and true) or true' = 'false or true' = true — the opposite of grouping-or-first-diverges-from-and-first, proving the parenthesization (not the operator order) decides which sub-expression is evaluated together.

Template

{{ (a and b) or c }}

Context

{
    "a": false,
    "b": true,
    "c": true
}

Output

true

both-sides-grouped-in-if-block

Parenthesized chains on both sides of an outer 'and', inside an #if block: '(a or b) and (c or d)' with a=false, b=true, c=false, d=false evaluates '(false or true) and (false or false)' = 'true and false' = false, so the else branch renders.

Template

{{#if (a or b) and (c or d) }}yes{{else}}no{{/if}}

Context

{
    "a": false,
    "b": true,
    "c": false,
    "d": false
}

Output

no

nested-grouping-flips-result

Nested grouping 'a and (b or (c and d))' with a=true, b=false, c=true, d=false evaluates the innermost 'c and d' = false first, then 'b or false' = false, then 'true and false' = false.

Template

{{ a and (b or (c and d)) }}

Context

{
    "a": true,
    "b": false,
    "c": true,
    "d": false
}

Output

false

nested-grouping-with-true-d

Same nested template with d flipped to true: innermost 'c and d' = true, then 'b or true' = true, then 'true and true' = true — showing the nested group's value drives the outer result.

Template

{{ a and (b or (c and d)) }}

Context

{
    "a": true,
    "b": false,
    "c": true,
    "d": true
}

Output

true

transform-inside-parenthesized-operand

A transform applied inside a parenthesized operand runs before the outer comparison: '(items | size) > 0' resolves the group's chain (identifier 'items' piped through 'size') to a number, then compares it against the literal 0.

Template

{{#if (items | size) > 0 }}nonempty{{else}}empty{{/if}}

Context

{
    "items": [
        1,
        2,
        3
    ]
}

Output

nonempty

transform-inside-parenthesized-operand-empty

Same template as transform-inside-parenthesized-operand, but with an empty array: '(items | size) > 0' resolves to '0 > 0' = false, so the else branch renders.

Template

{{#if (items | size) > 0 }}nonempty{{else}}empty{{/if}}

Context

{
    "items": []
}

Output

empty

standalone-grouped-expression-interpolated

A standalone parenthesized expression chain as the entire interpolated expression: '{{ (a or b) }}' renders the boolean result of the grouped 'or' directly.

Template

{{ (a or b) }}

Context

{
    "a": false,
    "b": true
}

Output

true

Source fixture: render/parenthesized-logic.json