DomBuilder
Dombuilder is a simple library that makes it easy to generate dom nodes from a JSON-like structure.
Usage
The module is a single function exported as the global domBuilder
or through an AMD style module as the dombuilder
package.
var $ = {};
var template = [
[".profile",
[".left.column",
["#date", new Date().toString() ],
["#address", "Sunnyvale, California" ]
],
[".right.column", { onclick: function (evt) { alert("Foo!"); } },
["#email", "tim@creationix.com" ],
["#bio", "Cool Guy" ]
]
],
[".form",
["input$inputField"],
["button", {onclick: function () { alert($.inputField.value); }}, "Click Me"]
],
["hr", {
css: {width:"100px",height:"50px"},
$: function (hr) { console.log(hr); }
}],
["p", "Inspect the source (not view source) to see how clean this dom is!"]
];
var root = domBuilder(template, $);