be-restated
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

be-restated

be-restated is one of a trio of element decorators / behaviors that takes advantage of the buried treasure that is XSLT, built into the browser.

The differences are summarized in the table below.

Bottom line, be-restated focuses on the following problem statements:

  1. Extracting the data from server-rendered HTML, in partnership with obj-xml.
  2. Providing derived content from other content. For example, generating a table of contents based on the contents of the page.
The roles of be-restated, be-metamorphic, be-ferried
Decorator/behavior Problem statements Notes
be-restated
  1. Extracting the data from server-rendered HTML, in partnership with obj-xml
  2. Providing derived content from other content. For example, generating a table of contents based on the contents of the page.
be-metamorphic
  1. Replace existing content with structurally different content.
  2. Replace HTML optimized for first paint, composed of native HTML elements, with markup consisting of design library tags, once the design library has been downloaded
be-ferried
  1. Make a replica of the light children, and transform it into the markup that makes sense within the Shadow DOM realm.

Syntax

<table-of-contents be-restated='{
    "from": "main",
    "xslt": "toc.xslt"
}'>
</table-of-contents>
...
<main>
    <h1>Heading 1</h1>
    <section>
        <h2>Heading 2</h2>
    </section>
    <section>...</section>
    <template be-a-beacon></template>
</main>

What this does:

  1. If be-restated can't locate main, it attaches an event handler to the host or document.body, listening for the event be-a-beacon emits: "i-am-here". Every time such an event occurs, searches the host's Shadow DOM, or document.body for element "main".
  2. Once element "main" is found, moves the beacon event listener to the main element.
  3. If the template[be-a-beacon] element is found, xslt is performed with the content of the main element, and the table-of-contents light children are populated from the result.
  4. If the event handler on the main element picks up "i-am-here" messages going forward, it re-does step 3.

Package Sidebar

Install

npm i be-restated

Weekly Downloads

1

Version

0.0.3

License

MIT

Unpacked Size

15 kB

Total Files

8

Last publish

Collaborators

  • bahrus