Interface TwingSynchronousEnvironment

interface TwingSynchronousEnvironment {
    cache: null | TwingSynchronousCache;
    charset: string;
    dateFormat: string;
    dateIntervalFormat: string;
    escapingStrategyHandlers: Record<string, 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;
}

Properties

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

Methods

  • Convenient method that renders a template from its name.

    Parameters

    • name: string
    • context: Record<string, any>
    • Optionaloptions: {
          sandboxed?: boolean;
          strict?: boolean;
      }
      • Optionalsandboxed?: boolean
      • Optionalstrict?: 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;
      }
      • Optionalsandboxed?: boolean
      • Optionalstrict?: boolean

    Returns {
        data: string;
        sourceMap: RawSourceMap;
    }

    • data: string
    • sourceMap: RawSourceMap