Class RootTemplate<T, R>

A template that can be used to render the root HTML content. Automatically adds a doctype and root tag to the rendered content.

Type Parameters

Hierarchy (view full)

Constructors

  • Creates a new root template.

    Type Parameters

    Parameters

    • content: TemplateContent | ((params) => TemplateContent | Promise<TemplateContent>)

      The content of the template, or a function that returns the content.

    • doctype: null | string = '<!doctype html>'

      The doctype tag to use for the template. Defaults to <!doctype html>. Set to null to disable.

    • rootTag: R | ((params, content) => Tag<R, SelectorName<R>> | Promise<Tag<R, SelectorName<R>>>) = ...

      The root tag to use for the template. Defaults to html.

    • rootAttributes: Partial<Attributes<SelectorName<R>>> = ...

      The attributes to set on the root tag. Defaults to {lang: 'en'} if the root tag is html.

    Returns RootTemplate<T, R>

Properties

content: TemplateContent | ((params) => TemplateContent | Promise<TemplateContent>)

The content of the template, or a function that returns the content.

Type declaration

    • (params): TemplateContent | Promise<TemplateContent>
    • Parameters

      • params: T

      Returns TemplateContent | Promise<TemplateContent>

doctype: null | string = '<!doctype html>'

The doctype tag to use for the template. Defaults to <!doctype html>. Set to null to disable.

rootAttributes: Partial<Attributes<SelectorName<R>>> = ...

The attributes to set on the root tag. Defaults to {lang: 'en'} if the root tag is html.

rootTag: R | ((params, content) => Tag<R, SelectorName<R>> | Promise<Tag<R, SelectorName<R>>>) = ...

The root tag to use for the template. Defaults to html.

Type declaration

Methods

  • Renders the template with the given params (if content is a function).

    Parameters

    • params: T

      The params to pass to the template.

    Returns Promise<RawContent>

    The rendered template as a RawContent instance.

  • Renders the template with the given params (if content is a function).

    Parameters

    • params: T

      The params to pass to the template.

    Returns Promise<string>

    The rendered template.

Generated using TypeDoc