If / Else
If / Else

Flat conditional that shows or hides content based on a field predicate.

If is a flat conditional for the current item (inside Each / ObjectList) or a standalone object. The alternative branch is marked with a single self-closing <Else /> inside the same <If>.

Supported props

PropTypeRequiredPurpose
fieldstringyesField to test
eqstringnoMatches when the field equals this value
neqstringnoMatches when the field does not equal this value
existstrue/falsenoMatches when the field is present / non-empty
emptytrue/falsenoMatches when the field is missing / empty
model_keystringnoStandalone use (outside iteration)
objectstringnoStandalone use — object id relative to the model

Predicates are combined with AND. Only eq, neq, exists, and empty are supported (no in / gt / lt).

Separate branches with blank lines

Branches are split by a top-level <Else />. Put the then-branch, the <Else /> marker, and the else-branch on separate lines (blank-line separated) so the marker is detected. Nested <If> and else if chains are not supported.

Condition only

<Each model_key="deployment" objects="iomodel.*">
  <If field="type" eq="statefulset">
    <ObjectLink /> (stateful)
  </If>
</Each>

With an alternative branch

<Each model_key="deployment" objects="iomodel.*">
<If field="type" eq="statefulset">

<ObjectLink /> — stateful

<Else />

<ObjectLink /> — stateless

</If>
</Each>

Standalone

Outside an iteration, pass model_key and object:

<If model_key="deployment" object="iomodel.postgres" field="type" eq="statefulset">

PostgreSQL is a stateful workload.

</If>

Common pitfalls

  • Inline <Else /> without blank-line separation is not detected as a branch split
  • If cannot contain another If (no nesting, no else if)
  • For “value or default” without branching, prefer Field’s fallback

Last updated on