frag-factory

DOM fragment helper

Usage no npm install needed!

<script type="module">
  import fragFactory from 'https://cdn.skypack.dev/frag-factory';
</script>

README

Frag Factory

Frag Factory is a small helper for constructing DOM fragments from simple objects.

Usage

var FragFactory = require('frag-factory');

var fragment = FragFactory.create([
  {
    tag: 'img',
    src: 'http://www.ntnusymbiosis.com/wp-content/uploads/2011/09/thumbs-up.jpg',
    width: 200
  },
  {
    tag: 'a',
    href: 'https://awesome-site.io',
    text: "Let's go there!",
    style: 'display:block; font-size:1.5em; text-decoration:none;'
  },
  {
    tag: 'ul',
    children: [
      {
        tag: 'li',
        text: "It's just one thing"
      },
      {
        tag: 'li',
        text: "After the other"
      }
    ]
  }
]);

document.getElementById('app').appendChild(fragment);