Documentation
    Preparing search index...

    Interface TwingSynchronousEnvironment

    interface TwingSynchronousEnvironment {
        cache: null | TwingSynchronousCache;
        charset: string;
        dateFormat: string;
        dateIntervalFormat: string;
        escapingStrategyHandlers: Record<
            TwingEscapingStrategy,
            TwingEscapingStrategyHandler,
        >;
        filters: Map<string, TwingSynchronousFilter>;
        functions: Map<string, TwingSynchronousFunction>;
        globals: Map<string, any>;
        loader: TwingSynchronousLoader;
        numberFormat: TwingNumberFormat;
        sandboxPolicy: TwingSandboxSecurityPolicy;
        tests: Map<string, TwingSynchronousTest>;
        timezone: string;
        addExtension(extension: TwingSynchronousExtension): void;
        addFilter(filter: TwingSynchronousFilter): void;
        addFunction(aFunction: TwingSynchronousFunction): void;
        addNodeVisitor(visitor: TwingNodeVisitor): void;
        addOperator(operator: TwingOperator): void;
        addTagHandler(parser: TwingTagHandler): void;
        addTest(test: TwingSynchronousTest): void;
        loadTemplate(name: string, from?: null | string): TwingSynchronousTemplate;
        parse(
            stream: TwingTokenStream,
            options?: TwingParserOptions,
        ): TwingTemplateNode;
        registerEscapingStrategy(
            handler: TwingEscapingStrategyHandler,
            name: string,
        ): void;
        render(
            name: string,
            context: Record<string, any>,
            options?: { sandboxed?: boolean; strict?: boolean },
        ): string;
        renderWithSourceMap(
            name: string,
            context: Record<string, any>,
            options?: { sandboxed?: boolean; strict?: boolean },
        ): { data: string; sourceMap: RawSourceMap };
        tokenize(source: TwingSource): TwingTokenStream;
    }
    Index

    Properties

    cache: null | TwingSynchronousCache
    charset: string
    dateFormat: string
    dateIntervalFormat: string
    escapingStrategyHandlers: Record<
        TwingEscapingStrategy,
        TwingEscapingStrategyHandler,
    >
    filters: Map<string, TwingSynchronousFilter>
    functions: Map<string, TwingSynchronousFunction>
    globals: Map<string, any>
    numberFormat: TwingNumberFormat
    tests: Map<string, TwingSynchronousTest>
    timezone: string

    Methods

    • Loads a template by its name.

      Parameters

      • name: string

        The name of the template to load

      • Optionalfrom: null | string

        The name of the template that requested the load

      Returns TwingSynchronousTemplate

      When the template cannot be found

      When an error occurred during the parsing of the source

    • Convenient method that renders a template from its name.

      Parameters

      • name: string
      • context: Record<string, any>
      • Optionaloptions: { sandboxed?: boolean; strict?: boolean }

      Returns 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>
      • Optionaloptions: { sandboxed?: boolean; strict?: boolean }

      Returns { data: string; sourceMap: RawSourceMap }