data include - speced/respec GitHub Wiki

data-include

Applies to: any element

Fetches an external file and inserts its content as children of the element (or replaces the element entirely with data-include-replace).

Usage

<section data-include="sections/introduction.html"></section>
<section data-include="sections/api.md"
         data-include-format="markdown"></section>
<section data-include="sections/header.html"
         data-include-replace="true"></section>

Related attributes

Attribute Description
data-include-format Format of the included content: "html" (default) or "markdown"
data-include-replace If present, the element is replaced rather than having content inserted into it
data-oninclude Name of a function to call to transform the included content before insertion

Notes

  • Paths are relative to the including document
  • Includes are recursive up to a maximum depth of 3
  • Included content is processed by ReSpec just as if it were in the original document (WebIDL, definitions, links, etc. all work)
  • Must be served over HTTP/HTTPS — does not work with file:/// URLs. Use a local server during development.
  • Circular includes are not detected — avoid include loops
⚠️ **GitHub.com Fallback** ⚠️