/create-html-template-element

Create an HTML <template> with content.

Primary LanguageJavaScriptMIT LicenseMIT

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 createHTMLTemplateElement from 'create-html-template-element';

CommonJS Module:

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

Usage

As a tagged template literal (notice the syntax highlighting):

const html = createHTMLTemplateElement;

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

As a regular function:

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