IrisJS

Namespace: frontend

frontend

Members

(static) hook_display_error_page

Return a friendly error page to the user

Expects thisHook.const.error to be an HTTP error code.

Source:

(static) hook_frontend_handlebars_extend

Template engine processing - Handlebars extending

Attaches partials and extensions onto handlebars templating engine

Source:

(static) hook_frontend_template

Template engine processing - Handlebars templating

Parses data.html through a templating library: Handlebars in the default handler.

Source:

(static) hook_frontend_template_context

Prepare context for template from custom template variables

Source:

(static) hook_frontend_template_parse

Parse frontend template

Hook into the template parsing process using this. Inside, one can run functions such as parseEmbed on the current state of the template.

Source:

Methods

(static) displayErrorPage(code, req, res)

Respond to a request with an error page.

Wrapper for hook_display_error_page; returns error page HTML on response automatically.

Parameters:
Name Type Description
code number

The HTTP error code to return the page for

req object

The current Express request object

res object

The current Express response object

Source:

(static) findTemplate(paths, stringopt)

Function for finding most specific matching template

Parameters:
Name Type Attributes Description
paths Array.<string>

Paths to search for templates in

string extension <optional>

File extension to search for. Defaults to html.

Source:
Returns:

promise which, if successful, takes the template HTML output as its first argument.

(static) getTemplate(entity, authPass, optionalContextopt)

Returns a parsed HTML template for an entity, including sub templates

Parameters:
Name Type Attributes Description
entity object

the entity to work from

authPass object

the current user's authPass (use "root" for full access)

optionalContext object <optional>

additional context to make available as a template variable

Source:
Returns:

a promise which, if successful, has the parsed HTML template as its first argument.

(static) parseEmbed(prefix, html, action)

Parse embeds in template HTML

An 'embed' is a type of directive, embedded in HTML, of the form [[[prefix ]]].

Embeds are intended to be replaced with code generated from the data provided.

For example, the embed [[[form example]]] would render the form named 'example.'

Parameters:
Name Type Description
prefix string

the 'prefix' used to identify the embed type

html string

the HTML to process; that contains the embeds that need to be parsed

action function

callback to be run on each embed parsed

Source:
Returns:

a promise which, if successful, takes the processed HTML as its first argument.

(static) parseTemplace(html, authPass, context)

Parse a template recursively (to catch nested embeds). Internal function for Frontend.

Parameters:
Name Type Description
html string

HTML of template to process

authPass object

authPass of current user

context object

extra variables to pass to templating engine. The property 'custom' is passed to hook_frontend_template_context

There are other functions that are intended to make parsing templates easier.

Source:
See:
  • parseEmbed
  • parseTemplateFile
Returns:

a promise which, if successful, takes an object with properties 'html' and 'variables',for the processed HTML and variables ready to pass to the templating engine, respectively.

(static) parseTemplateFile(templateName, wrapperTemplateName, parameters, authPass, req)

Parse a template from a file with parameters

Wraps and simplifies the process of loading a template file and parsing it.

Allows for processing two templates: a wrapper and an inner template. Wrapper is optional.

The inner template is inserted into the wrapper with the embed [[[MAINCONTENT]]].

Parameters:
Name Type Description
templateName string

file name of inner template file

wrapperTemplateName string

file name of wrapper template file

parameters object

extra variables to pass through to the templating system (via parseTemplate)

authPass object

the current user's authPass

req object

the Express request object

Source:
Returns:

a promise which, if successful, takes the output HTML as its first argument.