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
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``: Template
raw(): Template
apply(oldTree, string): Element
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
© Shannon Moeller me@shannonmoeller.com (shannonmoeller.com)
Licensed under MIT