JSPM

  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q27336F
  • License MIT

It's `innerHTML` for the modern world.

Package Exports

  • apply-html

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (apply-html) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

apply-html

NPM version Downloads Build Status Coverage Status

It's innerHTML for the modern world. Patches the contents of an existing element with a string.

Install

$ npm install --save apply-html

Usage

const { html, raw, apply } = require('apply-html');

const state = {
    salutation: 'Hello',
    target: '<em>World</em>'
};

const template = ({ salutation, target }) => html`
    <h1>${salutation} ${raw(target)}</h1>
`;

// document.body.innerHTML = template(state);
apply(document.body, template(state));

console.log(document.body.innerHTML);
// -> <h1>Hello <em>World</em></h1>

API

html`string`: Template

raw(string): Template

apply(element, string): element

Template Class

Contribute

Standards for this project, including tests, code coverage, and semantics are enforced with a build tool. Pull requests must include passing tests with 100% code coverage and no linting errors.

Test

$ npm test

Attribution


© Shannon Moeller me@shannonmoeller.com (shannonmoeller.com)

Licensed under MIT