@types/pug

  • Version 2.0.10
  • Published
  • 9.7 kB
  • No dependencies
  • MIT license

Install

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

Overview

TypeScript definitions for pug

Index

Namespaces

namespace pug

module 'pug' {}
  • Table of Contents

    - Options https://pugjs.org/api/reference.html#options - Methods https://pugjs.org/api/reference.html#methods

    The order of contents is according to pugjs API document.

function compile

compile: (template: string, options?: Options) => compileTemplate;
  • Compile a Pug template to a function which can be rendered multiple times with different locals.

function compileClient

compileClient: (template: string, options?: Options) => string;
  • Compile a Pug template to a string of JavaScript that can be used client side along with the Pug runtime.

function compileClientWithDependenciesTracked

compileClientWithDependenciesTracked: (
template: string,
options?: Options
) => { body: string; dependencies: string[] };
  • Compile a Pug template to an object of the form: { 'body': 'function (locals) {...}', 'dependencies': ['filename.pug'] } that can be used client side along with the Pug runtime. You should only use this method if you need dependencies to implement something like watching for changes to the Pug files.

function compileFile

compileFile: (path: string, options?: Options) => compileTemplate;
  • Compile a Pug template from a file to a function which can be rendered multiple times with different locals.

function compileFileClient

compileFileClient: (path: string, options?: Options) => string;
  • Compile a Pug template file to a string of JavaScript that can be used client side along with the Pug runtime.

function render

render: {
(template: string): string;
(template: string, options: Options & LocalsObject): string;
(template: string, callback: (err: Error, html: string) => void): void;
(
template: string,
options: Options & LocalsObject,
callback: (err: Error, html: string) => void
): void;
};
  • Compile a Pug template and render it without locals to html string.

  • Compile a Pug template and render it with locals to html string.

    Parameter options

    Pug Options and rendering locals

  • Compile a Pug template and render it without locals to html string.

    Parameter callback

    Node.js-style callback receiving the rendered results. This callback is called synchronously.

  • Compile a Pug template and render it with locals to html string.

    Parameter options

    Pug Options and rendering locals

    Parameter callback

    Node.js-style callback receiving the rendered results. This callback is called synchronously.

function renderFile

renderFile: {
(path: string): string;
(path: string, options: Options & LocalsObject): string;
(path: string, callback: (err: Error, html: string) => void): void;
(
path: string,
options: Options & LocalsObject,
callback: (err: Error, html: string) => void
): void;
};
  • Compile a Pug template from a file and render it without locals to html string.

  • Compile a Pug template from a file and render it with locals to html string.

    Parameter options

    Pug Options and rendering locals

  • Compile a Pug template from a file and render it without locals to html string.

    Parameter callback

    Node.js-style callback receiving the rendered results. This callback is called synchronously.

  • Compile a Pug template from a file and render it with locals to html string.

    Parameter options

    Pug Options and rendering locals

    Parameter callback

    Node.js-style callback receiving the rendered results. This callback is called synchronously.

interface LocalsObject

interface LocalsObject {}
  • An object that can have multiple properties of any type.

index signature

[propName: string]: any;

    interface Options

    interface Options {}

      property basedir

      basedir?: string | undefined;
      • The root directory of all absolute inclusion.

      property cache

      cache?: boolean | undefined;
      • If set to true, compiled functions are cached. filename must be set as the cache key. Only applies to render functions. Defaults to false.

      property compileDebug

      compileDebug?: boolean | undefined;
      • If set to true, the function source will be included in the compiled template for better error messages (sometimes useful in development). It is enabled by default unless used with Express in production mode.

      property debug

      debug?: boolean | undefined;
      • If set to true, the tokens and function body are logged to stdout.

      property doctype

      doctype?: string | undefined;
      • If the doctype is not specified as part of the template, you can specify it here. It is sometimes useful to get self-closing tags and remove mirroring of boolean attributes; see doctype documentation for more information.

      property filename

      filename?: string | undefined;
      • The name of the file being compiled. Used in exceptions, and required for relative includes and extends. Defaults to 'Pug'.

      property filters

      filters?: any;
      • Hash table of custom filters. Defaults to undefined.

      property globals

      globals?: string[] | undefined;
      • Add a list of global names to make accessible in templates.

      property inlineRuntimeFunctions

      inlineRuntimeFunctions?: boolean | undefined;
      • Inline runtime functions instead of require-ing them from a shared version. For compileClient functions, the default is true so that one does not have to include the runtime. For all other compilation or rendering types, the default is false.

      property name

      name?: string | undefined;
      • The name of the template function. Only applies to compileClient functions. Defaults to 'template'.

      property pretty

      pretty?: boolean | string | undefined;
      • Adds whitespace to the resulting HTML to make it easier for a human to read using ' ' as indentation. If a string is specified, that will be used as indentation instead (e.g. '\t'). Defaults to false.

      property self

      self?: boolean | undefined;
      • Use a self namespace to hold the locals. It will speed up the compilation, but instead of writing variable you will have to write self.variable to access a property of the locals object. Defaults to false.

      type compileTemplate

      type compileTemplate = (locals?: LocalsObject) => string;
      • A function that can be use to render html string of compiled template.

      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/pug.

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