Girobusan · IMP! · Helpers

Helpers API methods


Please, keep in mind, that this API is at starting stage of development. We'll try to keep everything consistent and compatible, but changes may occur.

Core

register(name, helper, parameters_format , postprocessor)

This function must be called by helper, as soon as possible. Postprocessor is an optional parameter; a function, which will be called after processing all helpers. It will be called with two arguments: resulting HTML and source markdown, and must return HTML. The order of execution of posprocessors is not guaranteed! Be careful.

Parameters

  1. Name of the helper
  2. Helper object (more info in dev docs)
  3. Parameters format specifier, json , yaml or raw

Service

This functions, which may be used in your helpers.

defaultPreview(title,text)

Standard preview, with customizable title and text, which looks like this:

title
Some text

Parameters

  1. Title of the preview
  2. Text to display

defaultRender(name, params, params_raw, subname)

Default render function, which will render preload screen:

title

See dev doc for more info on defaultRender behavior.

Parameters

  1. Name of the helper
  2. Parsed parameters
  3. Raw parameters (as they were entered)
  4. Subname of the helper

errorNotice(title, text)

Standard error notice.

title: Some text

Parameters

  1. Title
  2. Text to display

attachScript(url)

Use this method for attaching external scripts. This method returns Promise which fulfilled when script is attached, or rejected, if not. You can return this Promise from your helpers init() function.

Parameter

URL of the script to attach.

packParams(params_raw, fold)

Encodes supplied string using encodeURI() function. If second parameter is true, result than split to stings no longer than 64 characters. Used for saving parameters in render() method.

unpackParams(packed)

Decodes result of the previous function.

parseYAML(string)

Parses YAML-formatted string. If string is empty, returns empty object.

escapeHTML(string)

Available in IMP! versions > 0.5. Escapes <, > and & .

unescapeHTML(string)

Available in IMP! versions > 0.5. Unescapes escaped string.