Skip to content

Conditionals ​

Use #if and #else to select content with a Bool condition. Conditions use the same typed expression grammar as calculations and bindings.

Basic syntax ​

sevenmark
{{{#let score = 85}}}
{{{#if score >= 60 ::
**Passed**
}}}
{{{#else :: Needs another attempt. }}}

The :: separator is required. A malformed conditional is a parser error. An #else belongs to the preceding #if; only whitespace can appear between them. Only the selected branch executes.

Bool conditions ​

A condition must produce Bool. Comparisons produce Bool; strings, numbers, and Null do not become Bool implicitly.

sevenmark
{{{#param enabled: Bool = false}}}
{{{#if enabled :: This feature is enabled. }}}
{{{#if !enabled :: This feature is disabled. }}}

Use &&, ||, and ! for Bool operations. && and || short-circuit, so the right expression executes only when needed.

sevenmark
{{{#let name = "Reader"}}}
{{{#let score = 85}}}
{{{#if !is_empty(name) && score >= 60 && score < 90 ::
Welcome, {{{#expr name}}}.
}}}

Comparisons include ==, !=, <, <=, >, and >=. Write separate comparisons joined by a logical operator; 0 < score < 100 is not valid. Equality does not parse strings as numbers. Use int(text) or decimal(text) when a conversion is intended.

Optional inputs ​

Input presence, Null, an empty String, zero, and false have distinct meanings:

sevenmark
{{{#param subtitle: String? = null}}}
{{{#if subtitle != null && !is_empty(subtitle) ::
Subtitle: {{{#expr subtitle}}}
}}}
{{{#if provided("subtitle") :: The caller supplied the subtitle input. }}}

provided checks caller presence. is_null checks Null. is_empty checks Null or an empty String, List, or Record. An undeclared name is an error; it does not silently become Null.

For a calculated value, use null coalescing or conditional selection:

sevenmark
{{{#param subtitle: String? = null}}}
{{{#let caption = subtitle ?? "No subtitle"}}}
{{{#let label = is_empty(caption) ? "Empty caption" : caption}}}
{{{#expr label}}}

Branch scope ​

Each branch has a child scope. It can shadow an outer binding, but its local bindings do not escape. The same name cannot be declared twice in one scope.

sevenmark
{{{#let label = "Standard"}}}
{{{#if true ::
{{{#let label = "Featured"}}}
Inside: {{{#expr label}}}
}}}
Outside: {{{#expr label}}}

The inside value is Featured; the outside value is Standard. Use a conditional value expression when a binding must be available after selection:

sevenmark
{{{#let environment = "production"}}}
{{{#let apiHost = environment == "production" ? "https://api.example.com" : "http://localhost:3000"}}}
Endpoint: {{{#expr apiHost}}}

Table rows and cells ​

At a table's row level, conditional content must contain complete rows:

sevenmark
{{{#let showDetails = true}}}
{{{#table
[[ [[Item]] [[Details]] ]]
{{{#if showDetails ::
[[ [[Sword]] [[Attack: 120]] ]]
}}}
}}}

Inside a row, it must contain complete cells:

sevenmark
{{{#let showStock = true}}}
{{{#table
[[ [[Product]] [[Price]] {{{#if showStock :: [[Stock]] }}} ]]
[[ [[Widget]] [[10]] {{{#if showStock :: [[5]] }}} ]]
}}}

List items ​

sevenmark
{{{#let showAdvanced = true}}}
{{{#list
[[Introduction]]
{{{#if showAdvanced :: [[Advanced topics]] [[Reference]] }}}
[[Summary]]
}}}

Structural conditions use the same strict Bool rules and child scopes as normal content. Combine #if/#else, #let, and nested #for blocks at row, cell, and list-item levels. Each block must produce complete content for that level. See iteration.