A utility class for managing and generating text using templates. This class acts as a wrapper of Handlebars, the engine employed to compile the templates We can register templates by name for reusing them, or create the text directly using a template.

Constructors

Methods

  • Generate a string with a template and the data to fill in

    Parameters

    • template: string

      A template

    • data: Object

      The data to fill in the template

    Returns string

    A string with the template filled in with the data

  • Create a string using a registered template using some data

    Parameters

    • name: string

      The name of a template already registered

    • data: Object

      The data employed to fill in the template

    Returns string

    A string with the corresponding template filled in using the data provided; or an empty string, if the template does not exist.

  • Register a template using a name

    Parameters

    • name: string

      Name of the template

    • template: string

      Template that must be registered

    Returns boolean

    False, if there is another template with this name, so the template is not registered; and true, otherwise