@types/nunjucks

  • Version 3.2.1
  • Published
  • 8.98 kB
  • No dependencies
  • MIT license

Install

npm i @types/nunjucks
yarn add @types/nunjucks
pnpm add @types/nunjucks

Overview

TypeScript definitions for nunjucks

Index

Functions

function compile

compile: (
src: string,
env?: Environment,
callback?: TemplateCallback<Template>
) => Template;

    function configure

    configure: {
    (options: ConfigureOptions): Environment;
    (path: string | string[], options?: ConfigureOptions): Environment;
    };

      function installJinjaCompat

      installJinjaCompat: () => void;

        function precompile

        precompile: (path: string, opts?: PrecompileOptions) => string;

          function precompileString

          precompileString: (src: string, opts?: PrecompileOptions) => string;

            function render

            render: {
            (name: string, context?: object): string;
            (name: string, context?: object, callback?: TemplateCallback<string>): void;
            };

              function renderString

              renderString: {
              (src: string, context: object): string;
              (src: string, context: object, callback?: TemplateCallback<string>): void;
              };

                Classes

                class Environment

                class Environment {}

                  constructor

                  constructor(loader?: ILoader | ILoader[], opts?: ConfigureOptions);

                    property options

                    options: { autoescape: boolean };

                      method addExtension

                      addExtension: (name: string, ext: Extension) => Environment;

                        method addFilter

                        addFilter: (
                        name: string,
                        func: (...args: any[]) => any,
                        async?: boolean
                        ) => Environment;

                          method addGlobal

                          addGlobal: (name: string, value: any) => Environment;

                            method express

                            express: (app: object) => void;

                              method getExtension

                              getExtension: (name: string) => Extension;

                                method getFilter

                                getFilter: (name: string) => (...args: any[]) => any;

                                  method getGlobal

                                  getGlobal: (name: string) => any;

                                    method getTemplate

                                    getTemplate: {
                                    (name: string, eagerCompile?: boolean): Template;
                                    (
                                    name: string,
                                    eagerCompile?: boolean,
                                    callback?: Callback<Error, Template>
                                    ): void;
                                    };

                                      method hasExtension

                                      hasExtension: (name: string) => boolean;

                                        method on

                                        on: (
                                        event: 'load',
                                        fn: (
                                        name: string,
                                        source: { src: string; path: string; noCache: boolean },
                                        loader: Loader
                                        ) => void
                                        ) => void;

                                          method removeExtension

                                          removeExtension: (name: string) => void;

                                            method render

                                            render: {
                                            (name: string, context?: object): string;
                                            (name: string, context?: object, callback?: TemplateCallback<string>): void;
                                            };

                                              method renderString

                                              renderString: {
                                              (name: string, context: object): string;
                                              (name: string, context: object, callback?: TemplateCallback<string>): void;
                                              };

                                                class FileSystemLoader

                                                class FileSystemLoader extends Loader implements ILoader {}

                                                  constructor

                                                  constructor(searchPaths?: string | string[], opts?: LoaderOptions);

                                                    method getSource

                                                    getSource: (name: string) => LoaderSource;

                                                      class Loader

                                                      class Loader {}

                                                        method emit

                                                        emit: (name: string, ...args: any[]) => void;

                                                          method extend

                                                          static extend: <LoaderClass extends typeof Loader>(
                                                          this: LoaderClass,
                                                          toExtend: ILoader
                                                          ) => LoaderClass;

                                                            method isRelative

                                                            isRelative: (filename: string) => boolean;

                                                              method on

                                                              on: (name: string, func: (...args: any[]) => any) => void;

                                                                method resolve

                                                                resolve: (from: string, to: string) => string;

                                                                  class NodeResolveLoader

                                                                  class NodeResolveLoader extends Loader implements ILoader {}

                                                                    constructor

                                                                    constructor(searchPaths?: string | string[], opts?: LoaderOptions);

                                                                      method getSource

                                                                      getSource: (name: string) => LoaderSource;

                                                                        class PrecompiledLoader

                                                                        class PrecompiledLoader extends Loader implements ILoader {}

                                                                          constructor

                                                                          constructor(compiledTemplates?: any[]);

                                                                            method getSource

                                                                            getSource: (name: string) => LoaderSource;

                                                                              class Template

                                                                              class Template {}

                                                                                constructor

                                                                                constructor(
                                                                                src: string,
                                                                                env?: Environment,
                                                                                path?: string,
                                                                                eagerCompile?: boolean
                                                                                );

                                                                                  method render

                                                                                  render: {
                                                                                  (context?: object): string;
                                                                                  (context?: object, callback?: TemplateCallback<string>): void;
                                                                                  };

                                                                                    class WebLoader

                                                                                    class WebLoader extends Loader implements ILoader {}

                                                                                      constructor

                                                                                      constructor(baseUrl?: string, opts?: WebLoaderOptions);

                                                                                        method getSource

                                                                                        getSource: (name: string) => LoaderSource;

                                                                                          Interfaces

                                                                                          interface ConfigureOptions

                                                                                          interface ConfigureOptions {}

                                                                                            property autoescape

                                                                                            autoescape?: boolean | undefined;

                                                                                              property express

                                                                                              express?: object | undefined;

                                                                                                property lstripBlocks

                                                                                                lstripBlocks?: boolean | undefined;

                                                                                                  property noCache

                                                                                                  noCache?: boolean | undefined;

                                                                                                    property tags

                                                                                                    tags?:
                                                                                                    | {
                                                                                                    blockStart?: string | undefined;
                                                                                                    blockEnd?: string | undefined;
                                                                                                    variableStart?: string | undefined;
                                                                                                    variableEnd?: string | undefined;
                                                                                                    commentStart?: string | undefined;
                                                                                                    commentEnd?: string | undefined;
                                                                                                    }
                                                                                                    | undefined;

                                                                                                      property throwOnUndefined

                                                                                                      throwOnUndefined?: boolean | undefined;

                                                                                                        property trimBlocks

                                                                                                        trimBlocks?: boolean | undefined;

                                                                                                          property watch

                                                                                                          watch?: boolean | undefined;

                                                                                                            property web

                                                                                                            web?:
                                                                                                            | {
                                                                                                            useCache?: boolean | undefined;
                                                                                                            async?: boolean | undefined;
                                                                                                            }
                                                                                                            | undefined;

                                                                                                              interface Extension

                                                                                                              interface Extension {}

                                                                                                                property tags

                                                                                                                tags: string[];

                                                                                                                  method parse

                                                                                                                  parse: (parser: any, nodes: any, lexer: any) => any;

                                                                                                                    interface ILoader

                                                                                                                    interface ILoader {}

                                                                                                                      property async

                                                                                                                      async?: boolean | undefined;

                                                                                                                        method getSource

                                                                                                                        getSource: {
                                                                                                                        (name: string): LoaderSource;
                                                                                                                        (name: string, callback: Callback<Error, LoaderSource>): void;
                                                                                                                        };

                                                                                                                          interface LoaderOptions

                                                                                                                          interface LoaderOptions {}

                                                                                                                            property noCache

                                                                                                                            noCache?: boolean;
                                                                                                                            • if true, the system will avoid using a cache and templates will be recompiled every single time

                                                                                                                            property watch

                                                                                                                            watch?: boolean;
                                                                                                                            • if true, the system will automatically update templates when they are changed on the filesystem

                                                                                                                            interface LoaderSource

                                                                                                                            interface LoaderSource {}

                                                                                                                              property noCache

                                                                                                                              noCache: boolean;

                                                                                                                                property path

                                                                                                                                path: string;

                                                                                                                                  property src

                                                                                                                                  src: string;

                                                                                                                                    interface PrecompileOptions

                                                                                                                                    interface PrecompileOptions {}

                                                                                                                                      property asFunction

                                                                                                                                      asFunction?: boolean | undefined;

                                                                                                                                        property env

                                                                                                                                        env?: Environment | undefined;

                                                                                                                                          property exclude

                                                                                                                                          exclude?: string[] | undefined;

                                                                                                                                            property force

                                                                                                                                            force?: boolean | undefined;

                                                                                                                                              property include

                                                                                                                                              include?: string[] | undefined;

                                                                                                                                                property name

                                                                                                                                                name?: string | undefined;

                                                                                                                                                  method wrapper

                                                                                                                                                  wrapper: (
                                                                                                                                                  templates: { name: string; template: string },
                                                                                                                                                  opts: PrecompileOptions
                                                                                                                                                  ) => string;

                                                                                                                                                    interface WebLoaderOptions

                                                                                                                                                    interface WebLoaderOptions {}

                                                                                                                                                      property async

                                                                                                                                                      async?: boolean;

                                                                                                                                                        property useCache

                                                                                                                                                        useCache?: boolean;

                                                                                                                                                          Type Aliases

                                                                                                                                                          type Callback

                                                                                                                                                          type Callback<E, T> = (err: E | null, res: T | null) => void;

                                                                                                                                                            type FileSystemLoaderOptions

                                                                                                                                                            type FileSystemLoaderOptions = LoaderOptions;

                                                                                                                                                              type NodeResolveLoaderOptions

                                                                                                                                                              type NodeResolveLoaderOptions = LoaderOptions;

                                                                                                                                                                type TemplateCallback

                                                                                                                                                                type TemplateCallback<T> = (err: lib.TemplateError | null, res: T | null) => void;

                                                                                                                                                                  Namespaces

                                                                                                                                                                  namespace lib

                                                                                                                                                                  namespace lib {}

                                                                                                                                                                    class TemplateError

                                                                                                                                                                    class TemplateError extends Error {}

                                                                                                                                                                      constructor

                                                                                                                                                                      constructor(message: string, lineno: number, colno: number);

                                                                                                                                                                        property cause

                                                                                                                                                                        cause?: Error;

                                                                                                                                                                          property colno

                                                                                                                                                                          colno: number;

                                                                                                                                                                            property lineno

                                                                                                                                                                            lineno: number;

                                                                                                                                                                              property message

                                                                                                                                                                              message: string;

                                                                                                                                                                                property name

                                                                                                                                                                                name: string;

                                                                                                                                                                                  property stack

                                                                                                                                                                                  stack: string;

                                                                                                                                                                                    namespace runtime

                                                                                                                                                                                    namespace runtime {}

                                                                                                                                                                                      class SafeString

                                                                                                                                                                                      class SafeString {}

                                                                                                                                                                                        constructor

                                                                                                                                                                                        constructor(val: string);

                                                                                                                                                                                          property length

                                                                                                                                                                                          length: number;

                                                                                                                                                                                            property val

                                                                                                                                                                                            val: string;

                                                                                                                                                                                              method toString

                                                                                                                                                                                              toString: () => string;

                                                                                                                                                                                                method valueOf

                                                                                                                                                                                                valueOf: () => string;

                                                                                                                                                                                                  Package Files (1)

                                                                                                                                                                                                  Dependencies (0)

                                                                                                                                                                                                  No dependencies.

                                                                                                                                                                                                  Dev Dependencies (0)

                                                                                                                                                                                                  No dev dependencies.

                                                                                                                                                                                                  Peer Dependencies (0)

                                                                                                                                                                                                  No peer dependencies.

                                                                                                                                                                                                  Badge

                                                                                                                                                                                                  To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                                                                  You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/nunjucks.

                                                                                                                                                                                                  • Markdown
                                                                                                                                                                                                    [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/nunjucks)
                                                                                                                                                                                                  • HTML
                                                                                                                                                                                                    <a href="https://www.jsdocs.io/package/@types/nunjucks"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>