create-html-template-element

1.0.0 • Public • Published

create-html-template-element NPM Version Build Status

Create an HTML <template> with content.

Installation

Node.js >= 10 is required. To install, type this at the command line:

npm install create-html-template-element

Importing

ES Module:

import html from 'create-html-template-element';

CommonJS Module:

const html = require('create-html-template-element');

Usage

As a tagged template literal:

const TEMPLATE = html`
  <elm attr="val">txt</elm>
`;
//-> HTMLTemplateElement

As a regular function:

const TEMPLATE = html(`
  <elm attr="val">txt</elm>
`);
//-> HTMLTemplateElement

With custom document (useful for jsdom):

const TEMPLATE = html(`<elm attr="val">txt</elm>`, iframe.contentWindow.document);
//-> HTMLTemplateElement

Readme

Keywords

Package Sidebar

Install

npm i create-html-template-element

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

4.72 kB

Total Files

6

Last publish

Collaborators

  • stevenvachon