Plugin

Plugin

Create a new Plugin.

Constructor

new Plugin(name, pluginFunction) → {Plugin}

Source:
Examples
new Plugin('phtml-test', pluginOptions => {
  // initialization logic

  return {
    Element (element, result) {
      // runtime logic, do something with an element
    },
    Root (root, result) {
      // runtime logic, do something with the root
    }
  }
})
new Plugin('phtml-test', pluginOptions => {
  // initialization logic

  return (root, result) => {
    // runtime logic, do something with the root
  }
})
Parameters:
Name Type Description
name String

Name of the Plugin.

pluginFunction function

Function executed by the Plugin during initialization.

Returns:
Type
Plugin

Methods

process(input, processOptions, pluginOptions) → {ResultPromise}

Source:

Process input with options and plugin options and return the result.

Example
plugin.process('some html', processOptions, pluginOptions)
Parameters:
Name Type Description
input String

Source being processed.

processOptions ProcessOptions

Custom settings applied to the Result.

pluginOptions Object

Options passed to the Plugin.

Returns:
Type
ResultPromise