Brevmal struktur og Scopes
En brevmal inneholder en nøstet struktur av elementer som brukes til å representere innhold. Strukturen består av ulike DSL-scopes som gir deg tilgang til relevante funksjoner på hvert nivå.
Scope-hierarki
createTemplate(...) { TemplateRootScope
title { PlainTextScope
text(...)
}
outline { OutlineScope
title1 { PlainTextScope }
paragraph { ParagraphScope
text(...)
list { item { TextScope } }
}
includePhrase(OutlinePhrase)
}
includeAttachment(attachment, data)
}
TemplateRootScope
Ytterste scope - definerer brevets struktur:
TemplateRootScope {
title { PlainTextScope }
outline { OutlineScope }
includeAttachment(attachment, data)
includeAttachmentIfNotNull(attachment, nullableData)
}
OutlineScope
Hoveddelen av brevet - overskrifter og avsnitt:
OutlineScope {
includePhrase(OutlinePhrase)
title1 { PlainTextScope }
title2 { PlainTextScope }
title3 { PlainTextScope }
paragraph { ParagraphScope }
}
ParagraphScope
Inne i avsnitt - tekst, lister, tabeller:
ParagraphScope {
includePhrase(ParagraphPhrase)
includePhrase(TextOnlyPhrase)
includePhrase(PlainTextPhrase)
text(...)
list { ... }
table { ... }
formText()
formChoice()
newline()
}
TextScope
Tekst med formattering:
TextScope {
includePhrase(TextOnlyPhrase)
includePhrase(PlainTextPhrase)
text(...)
newLine()
}