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
| Prop | Type | Required | Purpose |
|---|---|---|---|
field | string | yes | Field to test |
eq | string | no | Matches when the field equals this value |
neq | string | no | Matches when the field does not equal this value |
exists | true/false | no | Matches when the field is present / non-empty |
empty | true/false | no | Matches when the field is missing / empty |
model_key | string | no | Standalone use (outside iteration) |
object | string | no | Standalone 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 Ifcannot contain anotherIf(no nesting, noelse if)- For “value or default” without branching, prefer
Field’sfallback
Last updated on