Ta-Dom! 🎉
A tiny, functional helper library for generating DOM elements. Inspired in part by the jade templating engine for node.
How it works
Ta-Dom generates a bunch of named global functions that return an HTML element with the matching tag name. The optional attributes parameter is a plain object whose key/value pairs make up the desired attributes. The optional content param can hold text content, or any number of other elements.
;
Event listeners can also be specified in the attributes object by specifying the name of the event prefixed with 'on-' and a function defining the event handler.
;
Examples
generate a single div element with a class:
;
a really bare header:
;
with some text content:
;
Hello, World!
with some nested elements:
;
Hello, World! HEADER blah blah blah
Create re-usable modules:
const myArticle = { return ;}; ;
My Favorite Things Foo and bar. About Bananas Yellow and delicious.
Using some fancy component library, define a function to instantiate your components:
const myElement = ;;
For more examples, check out the examples
directory.
Testing
Ta-dom uses Karma for unit testing. To run tests:
npm test