whits
    Preparing search index...

    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 Summary)

    Index

    Constructors

    • Creates a new root template.

      Type Parameters

      Parameters

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

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

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

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

      • rootTag:
            | R
            | (
                (
                    params: T,
                    content: RawContent,
                ) => 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: T) => TemplateContent | Promise<TemplateContent>)

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

    doctype: string | null = '<!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: T,
                content: RawContent,
            ) => Tag<R, SelectorName<R>> | Promise<Tag<R, SelectorName<R>>>
        ) = ...

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

    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.