Skip to content

Latest commit

 

History

History
37 lines (20 loc) · 1.42 KB

API.md

File metadata and controls

37 lines (20 loc) · 1.42 KB

API Reference

In order to start using the Templater, you only need to import it.

Methods

Templater(template, schema, options)

Require in the module and call it with the template you want hydrated, an optional Joi schema, and any options. Returns a promise.

template

The template to be hydrated. Can be passed in as a JSON string or an option. If not provided, this.config will be used.

If the {{}} template handlebar is interpolated in a string (/route/{{example.id}}) then the returned value will be a string. If the template handlebar is the entire template value ({{example}}) then the returned value will be whatever the target value is.

schema

An optional joi schema. Validation will be done against the hydrated object. This is only used if you pass in an object.

options

hydrationContext

Used to override the default context from this.contexts

joiOptions

Passes options (such as allowUnknown) to the Joi.validate call if a schema is provided.