Options
All
  • Public
  • Public/Protected
  • All
Menu

Provides the functionality to render templates with {{mustaches}}.

Hierarchy

  • MustacheStatic

Index

Properties

Context

Represents a rendering context by wrapping a view object and maintaining a reference to the parent context.

Scanner

A simple string scanner that is used by the template parser to find tokens in template strings.

Writer

A Writer knows how to take a stream of tokens and render them to a string, given a context.

It also maintains a cache of templates to avoid the need to parse the same template twice.

escape

escape: function

Escapes HTML-characters.

param

The string to escape.

Type declaration

    • (value: string): string
    • Parameters

      • value: string

      Returns string

name

name: string

The name of the module.

tags

tags: string[]

The opening and closing tags to parse.

version

version: string

The version of the module.

Methods

clearCache

  • clearCache(): void
  • Clears all cached templates in this writer.

    Returns void

parse

  • parse(template: string, tags?: string[]): any
  • Parses and caches the given template in the default writer and returns the array of tokens it contains.

    Doing this ahead of time avoids the need to parse templates on the fly as they are rendered.

    Parameters

    • template: string

      The template to parse.

    • Optional tags: string[]

      The tags to use.

    Returns any

render

  • render(template: string, view: any | MustacheContext, partials?: any, tags?: string[]): string
  • Renders the template with the given view and partials using the default writer.

    Parameters

    • template: string

      The template to render.

    • view: any | MustacheContext

      The view to render the template with.

    • Optional partials: any

      Either an object that contains the names and templates of partials that are used in a template

      -- or --

      A function that is used to load partial template on the fly that takes a single argument: the name of the partial.

    • Optional tags: string[]

      The tags to use.

    Returns string

to_html

  • to_html(template: string, view: any | MustacheContext, partials?: any, send?: any): any
  • Renders the template with the given view and partials using the default writer.

    Parameters

    • template: string

      The template to render.

    • view: any | MustacheContext

      The view to render the template with.

    • Optional partials: any

      Either an object that contains the names and templates of partials that are used in a template

      -- or --

      A function that is used to load partial template on the fly that takes a single argument: the name of the partial.

    • Optional send: any

    Returns any

Generated using TypeDoc