@tmlmt/cooklang-parser / isStepActive
Function: isStepActive()
isStepActive(
step,variant?):boolean
Determines if a step is active (should be displayed) for a given variant.
- Steps with no
variantsproperty are always active. - When no variant is selected (default), steps tagged
[*]are active, and steps tagged with named variants are not. - When a named variant is selected, steps whose
variantsarray includes that name are active.
Parameters
step
The Step to check
variant?
string
The active variant name, or undefined/* for the default variant
Returns
boolean
true if the step should be displayed
Example
typescript
for (const item of section.content) {
if (item.type === 'step' && isStepActive(item, choices.variant)) {
// render step
}
}