npm.io
1.0.0 • Published 8 years ago

custom-html-tag

Licence
MIT
Version
1.0.0
Deps
0
Size
4 kB
Vulns
0
Weekly
0

custom-html-tag

usage

<script src="node_modules/custom-html-tag/html.js"></script>
<script src="node_modules/custom-renderer/render.js"></script>
<script>
  const html = new HTMLTag();
  const span = document.createElement('span');
  const template = html`<p>${'variable'}</p>`;
  render(span, template, {variable: 'hello'}); // <p>hello</p>
  render(span, template, {variable: 'hello world'}); // <p>hello world</p>
  
  // or
  // without custom-renderer
  const templateResult = template({variable: 'hello'});
  templateResult.changes.forEach(change => {
    change.from.value // previous value
    change.from.position // previous position
    change.to.value // new value
    change.to.position // new position
    // check https://github.com/vandeurenglenn/custom-renderer for an working example.
  });
</script>