@tmlmt/cooklang-parser / Section
Class: Section
Represents a recipe section
Wrapped as a Class and not defined as a simple Type to expose some useful helper classes (e.g. isBlank())
Constructors
Constructor
new Section(
name?,variants?,optional?):Section
Creates an instance of Section.
Parameters
name?
string = ""
The name of the section. Defaults to an empty string.
variants?
string[]
Optional variant names for this section.
optional?
boolean
Whether the section is optional.
Returns
Section
Properties
content
An array of steps and notes that make up the content of the section.
name
name:
string
The name of the section. Can be an empty string for the default (first) section.
Default Value
""
optional?
optionaloptional?:boolean
Whether the section has been marked as optional ([?])
variants?
optionalvariants?:string[]
Optional list of variant names this section belongs to.
Methods
isBlank()
isBlank():
boolean
Checks if the section is blank (has no name and no content). Used during recipe parsing
Returns
boolean
true if the section is blank, otherwise false.