A component to inject HTML nodes into the DOM.

The file '@src/hylo-components/Functional/Code Injection/hylo-inject-presets/hylo-inject-presets' contains presets for the properties "match" and "callback".

Properties

callback: Function

A callback which receives the matches as parameter. The returned value will be injected. Called with "await". Not sure if it has to return a Promise because of that ...

content: string | HTMLElement

The HTML node(s) to inject. If no content is defined, the inner HTML of the hylo-inject component is used.

live: boolean = false

By default the injection is only done when in prerender mode. To trigger the injection in browser mode set the "live" attribute.

match: RegExp

If provided, the "match" will be executed on the "content" and only matches will be injected.

position: "append" | "before" | "after" | "prepend" | "replace"

The position relative to the target where the HTML nodes will be injected.

If no target is defined, the default is "replace". Otherwise "append" is default.

target: string | HTMLElement

The target which defines the position where to inject the HTML nodes. If no target is defined, the component itself becomes the target.

wait: boolean = false

By default the injection happens on load of the hylo-inject component. If "wait" is set, the injection is not done automaticly but needs to be triggered by calling the "inject()" method.

Methods

  • Triggers the injection. Is called by the hylo-inject component automaticly unless the "wait" attribute is set. Then this method needs to be called manually.

    Returns Promise<void>

Generated using TypeDoc