minijinja-js
Version:
JavaScript bindings for minijinja
90 lines (89 loc) • 2.3 kB
TypeScript
/* tslint:disable */
/* eslint-disable */
type UndefinedBehavior = "strict" | "chainable" | "lenient" | "semi_strct";
/**
* Represents a MiniJinja environment.
*/
export class Environment {
free(): void;
constructor();
/**
* Registers a new template by name and source.
*/
addTemplate(name: string, source: string): void;
/**
* Removes a template by name.
*/
removeTemplate(name: string): void;
/**
* Clears all templates from the environment.
*/
clearTemplates(): void;
/**
* Renders a registered template by name with the given context.
*/
renderTemplate(name: string, ctx: any): string;
/**
* Renders a string template with the given context.
*
* This is useful for one-off template rendering without registering the template. The
* template is parsed and rendered immediately.
*/
renderStr(source: string, ctx: any): string;
/**
* Like `renderStr` but with a named template for auto escape detection.
*/
renderNamedStr(name: string, source: string, ctx: any): string;
/**
* Evaluates an expression with the given context.
*
* This is useful for evaluating expressions outside of templates. The expression is
* parsed and evaluated immediately.
*/
evalExpr(expr: string, ctx: any): any;
/**
* Registers a filter function.
*/
addFilter(name: string, func: Function): void;
/**
* Registers a test function.
*/
addTest(name: string, func: Function): void;
/**
* Enables python compatibility.
*/
enablePyCompat(): void;
/**
* Registers a value as global.
*/
addGlobal(name: string, value: any): void;
/**
* Removes a global again.
*/
removeGlobal(name: string): void;
/**
* Enables or disables debug mode.
*/
debug: boolean;
/**
* Enables or disables block trimming.
*/
trimBlocks: boolean;
/**
* Enables or disables the lstrip blocks feature.
*/
lstripBlocks: boolean;
/**
* Enables or disables keeping of the final newline.
*/
keepTrailingNewline: boolean;
/**
* Reconfigures the behavior of undefined variables.
*/
undefinedBehavior: UndefinedBehavior;
/**
* Configures the max-fuel for template evaluation.
*/
get fuel(): number | undefined;
set fuel(value: number | null | undefined);
}