Skip to content

Rule.io SDK


Rule.io SDK / rcml/src / createCaseElement

Function: createCaseElement()

createCaseElement(options): RcmlCase

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

Build an <rc-case> — one branch inside an <rc-switch>. Per the schema a case holds exactly one <rc-section> child. attrs.case-type selects the condition family (default, segment, tag, custom-field), and attrs.case-property / case-value / case-condition refine it.

Parameters

options

CaseElementOptions

options.attrs is the condition descriptor; options.children is a one-element tuple holding the section to render when the case matches.

Returns

RcmlCase

A typed RcmlCase node.

Throws

When attrs are invalid, the child is not an <rc-section>, or more than one child is supplied.

Example

ts
createCaseElement({
  attrs: { 'case-type': 'segment', 'case-condition': 'eq', 'case-value': 42 },
  children: [createSectionElement({ children: [...] })],
})