Class: HTML_ADAPTER

HTML_ADAPTER

HTML response adapter class which renders templates from provided data and template names

Constructor

new HTML_ADAPTER(options)

Parameters:
Name Type Description
options Object

Configurable options for HTML adapter

Properties
Name Type Attributes Default Description
engine Object <optional>
ejs

Defines which templating engine to use when rendering template files

Properties
Name Type Description
render function

If providing a custom rendering engine module must include a .render function which is synchronous or returns a Promise. Render function should also expect the following arguments in this order: (template_string, template_data, options)

engine_configuration Object <optional>

Defines a default set of configuration options that are passed to the rendering function

extname string <optional>

Name of a periodicjs extension. Used in finding valid template

themename string <optional>
"periodicjs.theme.default"

Name of a periodicjs theme. Used in finding valid template

locals Object <optional>
{}

Shared local values for rendering. Only used when express rendering is not available.

viewname string <optional>

Defines a default view name that should be used in rendering

fileext string <optional>
".ejs"

Defines the default extension name of the template file

Source:

Extends

  • JSON_Adapter

Methods

error(err, optionsopt, cb) → {Object}

Renders error view from template

Parameters:
Name Type Attributes Default Description
err *

Any error data that should be passed to template

options Object <optional>
{}

Configurable options for rendering see _ERROR for full details

Properties
Name Type Attributes Default Description
formatError function <optional>
_RENDER

Custom rendering function. It is not recommended to override the default value of this property and may no longer work properly

req Object <optional>

Express request object. If options.req and options.res are defined the express .render method will be used to render template

res Object <optional>

Express response object. If options.res and options.req are defined the express .render method will be used to render template

skip_response Boolean <optional>

If true function will resolve with the rendered

cb function

Optional callback function. If arugment is not passed function will

Source:
Returns:

Returns a Promise if cb arguement is not provided

Type
Object

render(data, optionsopt, cb) → {Object}

Renders HTML from provided data and template

Parameters:
Name Type Attributes Default Description
data Object

Data that is passed to render template

options Object <optional>
{}

Configurable options for rendering see _RENDER for full details

Properties
Name Type Attributes Default Description
formatRender function <optional>
_RENDER

Custom rendering function. It is not recommended to override the default value of this property and may no longer work properly

req Object <optional>

Express request object. If options.req and options.res are defined the express .render method will be used to render template

res Object <optional>

Express response object. If options.res and options.req are defined the express .render method will be used to render template

skip_response Boolean <optional>

If true function will resolve with the rendered template instead of sending a response

cb function

Optional callback function. If arugment is not passed function will

Source:
Returns:

Returns a Promise if cb arguement is not provided

Type
Object