Interface TwingEnvironment

interface TwingEnvironment {
    charset: string;
    dateFormat: string;
    dateIntervalFormat: string;
    escapingStrategyHandlers: Record<string, TwingEscapingStrategyHandler>;
    filters: Map<string, TwingFilter>;
    functions: Map<string, TwingFunction>;
    globals: TwingContext<string, any>;
    isStrictVariables: boolean;
    loader: TwingLoader;
    numberFormat: TwingNumberFormat;
    sandboxPolicy: TwingSandboxSecurityPolicy;
    tests: Map<string, TwingTest>;
    timezone: string;
    addExtension(extension): void;
    addFilter(filter): void;
    addFunction(aFunction): void;
    addNodeVisitor(visitor): void;
    addOperator(operator): void;
    addTagHandler(parser): void;
    addTest(test): void;
    loadTemplate(name, from?): Promise<TwingTemplate>;
    on(eventName, listener): void;
    parse(stream, options?): TwingTemplateNode;
    registerEscapingStrategy(handler, name): void;
    render(name, context): Promise<string>;
    renderWithSourceMap(name, context): Promise<{
        data: string;
        sourceMap: RawSourceMap;
    }>;
    tokenize(source): TwingTokenStream;
}

Properties

charset: string
dateFormat: string
dateIntervalFormat: string
escapingStrategyHandlers: Record<string, TwingEscapingStrategyHandler>
filters: Map<string, TwingFilter>
functions: Map<string, TwingFunction>
globals: TwingContext<string, any>
isStrictVariables: boolean
loader: TwingLoader
numberFormat: TwingNumberFormat
tests: Map<string, TwingTest>
timezone: string

Methods

  • Loads a template by its name.

    Parameters

    • name: string

      The name of the template to load

    • Optional from: null | string

      The name of the template that requested the load

    Returns Promise<TwingTemplate>

    Throws

    When the template cannot be found

    Throws

    When an error occurred during the parsing of the source

  • Register the passed listener...

    When a template is encountered, Twing environment emits a template event with the name of the encountered template and the source of the template that initiated the loading.

    Parameters

    • eventName: "load"
    • listener: ((name, from) => void)
        • (name, from): void
        • Parameters

          • name: string
          • from: null | string

          Returns void

    Returns void

  • Convenient method that renders a template from its name.

    Parameters

    • name: string
    • context: Record<string, any>

    Returns Promise<string>

  • Convenient method that renders a template from its name and returns both the render result and its belonging source map.

    Parameters

    • name: string
    • context: Record<string, any>

    Returns Promise<{
        data: string;
        sourceMap: RawSourceMap;
    }>

Generated using TypeDoc