Skip to content

Instantly share code, notes, and snippets.

@defims
Forked from Tiller/LICENSE.txt
Last active June 13, 2016 11:09
Show Gist options
  • Save defims/a1fc9b37c69999fb60a0f739734196ab to your computer and use it in GitHub Desktop.
Save defims/a1fc9b37c69999fb60a0f739734196ab to your computer and use it in GitHub Desktop.
140byt.es -- YET ANOTHER DOM BUILDER §
var create = function(e,b,i){
e=document.createElement(e); // Create the HTML element. e(e) => /body/(/body/) => [body] => body
for(i in b)e[i]=b[i]; // Apply all the gived-attributes
return function(){ // function to append childs
for(i=0;b=arguments[i++];) // lists every childs
e.appendChild(b); // and appends them
return e // then, return the DOM element
}
};
export function(e,b,i){e=document.createElement(e);for(i in b)e[i]=b[i];return function(){for(i=0;b=arguments[i++];)e.appendChild(b);return e}}
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
{
"name": "YetAnotherDomBuilder",
"description": "This DomBuilder ALSO builds a dom ! But it ALSO takes attributes in argument §",
"keywords": [ "dom", "dombuilder", "dom builder" ],
"version": "0.1.0"
}
<!DOCTYPE html>
<html>
<head>
<title>AGAIN AND AGAIN AND AGAIN AND AGAIN</title>
</head>
<body>
<div id="ret"></div>
<script>
// write a small example that shows off the API for your example
// and tests it in one fell swoop.
var create = function(e,b,i){e=document.createElement(e);for(i in b)e[i]=b[i];return function(){for(i=0;b=arguments[i++];)e.appendChild(b);return e}};
document.getElementById("ret").appendChild(
create('DIV', {align: 'center', innerHTML: 'Trololo<br/>'})(
create('UL', {id: 'ul'})(
create('LI', {innerHTML: 'This is the 1st li !'})(),
create('LI')(
create('UL')(
create('LI', {innerHTML: 'A 2nd level li !'})(),
create('LI', {innerHTML: 'And another one !'})()
)
)
),
create('SPAN')(document.createTextNode('Thanks you <3')),
create('div')()
)
);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment