Skip to content

Rule.io SDK


Rule.io SDK / rcml/src / createSwitchElement

Function: createSwitchElement()

createSwitchElement(options): RcmlSwitch

Defined in: rcml/src/email/create-rcml-element.ts:736

Build an <rc-switch> container — evaluates its <rc-case> children in order at send time and renders the first matching case's section. Use alongside createCaseElement for subscriber-segment / tag / custom-field conditional content.

Parameters

options

SwitchElementOptions

options.children is the list of <rc-case> branches.

Returns

RcmlSwitch

A typed RcmlSwitch node.

Throws

When any child is not an <rc-case>.

Example

ts
createSwitchElement({
  children: [
    createCaseElement({ attrs: { 'case-type': 'default' }, children: [section] }),
  ],
})