-
-
Save Tiller/1009208 to your computer and use it in GitHub Desktop.
140byt.es -- DOM Builder §
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var create = function(e,b,i){ // e: regex that contrains the tag name; | |
// b: one argument of the 2nd function; | |
// i: Counter | |
e = document.createElement(e); // Create the element. e(e) for : /body/.exec(/body/) => ['body'] => 'body' | |
return function(){ // To append the childs | |
for (i=0;b=arguments[i++];) // List of childs | |
b[0] ? // If it's a string (I know, bad idea) | |
e.innerHTML+=b // Write the text | |
: | |
e.appendChild(b); // Else, append the element | |
return e; // Then, return the element | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function(e,b,i){e=document.createElement(e);return function(){for(i=0;b=arguments[i++];)b[0]?e.innerHTML+=b:e.appendChild(b);return e}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "DaDomBuilder", | |
"description": "this domBuilder, BUILDS A DOM §", | |
"keywords": [ | |
"dom", | |
"dombuilder", | |
"dom builder" | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Like a Foo</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);return function(){for(i=0;b=arguments[i++];)b[0]?e.innerHTML+=b:e.appendChild(b);return e}}; | |
document.getElementById("ret").appendChild( | |
create('DIV')( | |
create('UL')( | |
create('LI')('This is the 1st li !'), | |
create('LI')( | |
create('UL')( | |
create('LI')('A 2nd level li !'), | |
create('LI')('And another one !') | |
) | |
) | |
), | |
create('SPAN')('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