Skip to main content

Interface: Markup

Defined in: src/markup.ts:22

All tags and the output statement in out template ASTs must implement the Markup interface.

Optional methods are for the benefit of static analysis, and can be omitted from custom tags if static analysis is not needed.

Properties

blank

blank: boolean

Defined in: src/markup.ts:28

If true, indicates that this node renders to the empty string or a string containing only whitespace. This is used to suppress control flow blocks that don't contain text nodes or markup that contributes to the output.


tag

tag: string

Defined in: src/markup.ts:34

Name of the tag used for static analysis. Set tag to an empty string if it's not a tag or to silence it.


token

token: Token

Defined in: src/markup.ts:41

The token spanning the start of this node. In the absence of a more specific token from an Expression, use this token when throwing errors.

Methods

blockScope()?

optional blockScope(): Name[]

Defined in: src/markup.ts:78

Return an array of variable names that are in scope for the duration of this node's block.

This is used during static analysis to isolate and report global variables, excluding temporary block-scoped names.

Returns

Name[]


children()?

optional children(staticContext): Promise<Markup[]>

Defined in: src/markup.ts:57

Return an array of child markup nodes. This is used to traverse template syntax trees during static analysis.

Parameters

staticContext

RenderContext

Returns

Promise<Markup[]>


childrenSync()?

optional childrenSync(staticContext): Markup[]

Defined in: src/markup.ts:63

Return an array of child markup nodes. This is used to traverse template syntax trees during static analysis.

Parameters

staticContext

RenderContext

Returns

Markup[]


expressions()?

optional expressions(): Expression[]

Defined in: src/markup.ts:69

Return an array of child expression nodes. This is used to traverse template syntax trees during static analysis.

Returns

Expression[]


partial()?

optional partial(staticContext): Promise<Partial>

Defined in: src/markup.ts:89

Return meta data about partial templates rendered from this node.

Parameters

staticContext

RenderContext

Returns

Promise<Partial>


partialSync()?

optional partialSync(staticContext): Partial

Defined in: src/markup.ts:94

Return meta data about partial templates rendered from this node.

Parameters

staticContext

RenderContext

Returns

Partial


render()

render(context, buffer): Promise<void>

Defined in: src/markup.ts:46

Render this node to the output buffer with data from context.

Parameters

context

RenderContext

buffer

OutputBuffer

Returns

Promise<void>


renderSync()

renderSync(context, buffer): void

Defined in: src/markup.ts:51

Render this node to the output buffer with data from context.

Parameters

context

RenderContext

buffer

OutputBuffer

Returns

void


templateScope()?

optional templateScope(): Name[]

Defined in: src/markup.ts:84

Return an array of variable names this node adds to the template local scope (variables that remain in scope after the tag has been rendered).

Returns

Name[]