Interface TwingChainLoader

interface TwingChainLoader {
    exists: ((name: string, from: null | string) => Promise<boolean>);
    getSource: ((name: string, from: null | string) => Promise<null | TwingSource>);
    isFresh: ((name: string, time: number, from: null | string) => Promise<null | boolean>);
    loaders: TwingLoader[];
    resolve: ((name: string, from: null | string) => Promise<null | string>);
    addLoader(loader: TwingLoader): void;
}

Hierarchy (view full)

Properties

exists: ((name: string, from: null | string) => Promise<boolean>)

Check if we have the source code of a template, given its name.

Type declaration

    • (name, from): Promise<boolean>
    • Parameters

      • name: string

        The name of the template to check if we can load

      • from: null | string

        The source that initiated the template loading

      Returns Promise<boolean>

      If the template source code is handled by this loader or not

getSource: ((name: string, from: null | string) => Promise<null | TwingSource>)

Returns the source for a given template logical name.

Type declaration

    • (name, from): Promise<null | TwingSource>
    • Parameters

      • name: string

        The template logical name

      • from: null | string

        The source that initiated the template loading

      Returns Promise<null | TwingSource>

isFresh: ((name: string, time: number, from: null | string) => Promise<null | boolean>)

Returns true if the template is still fresh.

Type declaration

    • (name, time, from): Promise<null | boolean>
    • Parameters

      • name: string

        The template name

      • time: number

        Timestamp of the last modification time of the cached template

      • from: null | string

        The source that initiated the template loading

      Returns Promise<null | boolean>

      true if the template is fresh, false otherwise; null if it does not exist

TwingErrorLoader When name is not found

loaders: TwingLoader[]
resolve: ((name: string, from: null | string) => Promise<null | string>)

Resolve a template FQN from its name and the name of the template that initiated the loading.

Type declaration

    • (name, from): Promise<null | string>
    • Parameters

      • name: string

        The name of the template to load

      • from: null | string

        The source that initiated the template loading

      Returns Promise<null | string>

      The cache key

Methods