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
- Name of the helper
- Helper object (more info in dev docs)
- Parameters format specifier,
json
,yaml
orraw
Service
This functions, which may be used in your helpers.
defaultPreview(title,text)
Standard preview, with customizable title and text, which looks like this:
Some text
Parameters
- Title of the preview
- Text to display
defaultRender(name, params, params_raw, subname)
Default render function, which will render preload screen:
See dev doc for more info on defaultRender behavior.
Parameters
- Name of the helper
- Parsed parameters
- Raw parameters (as they were entered)
- Subname of the helper
errorNotice(title, text)
Standard error notice.
Parameters
- Title
- 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.