Options
All
  • Public
  • Public/Protected
  • All
Menu

This class does the heavy lifting of interpolation (putting the actual values in the template). This is created by the .compile() method and is used under the hood by .render(), renderFn() and renderFnAsync() functions.

Hierarchy

  • Renderer

Index

Constructors

Methods

Constructors

constructor

  • Creates a new Renderer instance. This is called internally by the compiler.

    throws

    TypeError if the token is invalid

    Parameters

    • tokens: Tokens

      the result of the .tokenize() function

    • Default value options: RendererOptions = {}

      some options for customizing the rendering process

    Returns Renderer

Methods

render

  • render(scope?: Scope): string
  • Replaces every path inside the template with values from the scope parameter.

    Parameters

    • Default value scope: Scope = {}

      An object containing values for paths from the the template. If it's omitted, we default to an empty object.

    Returns string

renderFn

  • Same as render but accepts a resolver function which returns a value for every path.

    Parameters

    Returns string

renderFnAsync

  • Same as render but accepts a resolver function which returns a promise that resolves to a value for every path.

    Parameters

    Returns Promise<string>