-
-
Save 0xdevalias/11339206 to your computer and use it in GitHub Desktop.
Revisions
-
0xdevalias revised this gist
Apr 27, 2014 . 1 changed file with 15 additions and 18 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,25 +1,22 @@ /* buildHtml - Helper method to construct html tags easily */ var buildHtml = function(tag, attrs, innerHtml) { var h = '<' + tag; for (var attr in attrs) { if(attrs[attr] === false) { continue; } h += ' ' + attr + '="' + attrs[attr] + '"'; } return h += innerHtml ? '>' + innerHtml + '</' + tag + '>' : '/>'; } buildHTML("a", { id: "mylink", href: "http://devalias.net/" }, "Glenn devalias Grant"); // outputs: <a id="mylink" href="http://devalias.net">Glenn devalias Grant</a> // or leave out the innerHtml buildHTML("input", { id: "myinput", type: "text", -
1Marc revised this gist
Jul 8, 2010 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -7,9 +7,7 @@ buildHTML = function(tag, html, attrs) { } var h = '<' + tag; for (attr in attrs) { if(attrs[attr] === false) continue; h += ' ' + attr + '="' + attrs[attr] + '"'; } return h += html ? ">" + html + "</" + tag + ">" : "/>"; -
1Marc revised this gist
Jul 7, 2010 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,13 @@ // my little html string builder buildHTML = function(tag, html, attrs) { // you can skip html param if (typeof(html) != 'string') { attrs = html; html = null; } var h = '<' + tag; for (attr in attrs) { if (attr == 'selected' && attrs[attr] == false) continue; if (attr == 'disabled' && attrs[attr] == false) continue; if (attr == 'checked' && attrs[attr] == false) continue; h += ' ' + attr + '="' + attrs[attr] + '"'; -
1Marc revised this gist
Jul 7, 2010 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,11 @@ function buildHTML(tag, html, attrs) { html = null; } var h = '<' + tag; for (attr in attrs) { if (attr == 'disabled' && attrs[attr] == false) continue; if (attr == 'checked' && attrs[attr] == false) continue; h += ' ' + attr + '="' + attrs[attr] + '"'; } return h += html ? ">" + html + "</" + tag + ">" : "/>"; } -
1Marc revised this gist
Jul 7, 2010 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ function buildHTML(tag, html, attrs) { } var h = '<' + tag; for (attr in attrs) h += ' ' + attr + '="' + attrs[attr] + '"'; return h += html ? ">" + html + "</" + tag + ">" : "/>"; } buildHTML("a", "Marc Grabanski", { -
1Marc revised this gist
Jul 7, 2010 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ // my little html string builder function buildHTML(tag, html, attrs) { // you can skip html param if (typeof(html) != 'string') { attrs = html; html = null; } -
1Marc created this gist
Jul 7, 2010 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ // my little html string builder function buildHTML(tag, html, attrs) { if (typeof(html) != 'string') { // you can skip html param attrs = html; html = null; } var h = '<' + tag; for (attr in attrs) h += ' ' + attr + '="' + attrs[attr] + '"'; return h + html ? ">" + html + "</" + tag + ">" : "/>"; } buildHTML("a", "Marc Grabanski", { id: "mylink", href: "http://marcgrabanski.com" }); // outputs: <a id="mylink" href="http://marcgrabanski.com">Marc Grabanski</a> // or leave out the html buildHTML("input", { id: "myinput", type: "text", value: "myvalue" }); // outputs: <input id="myinput" type="text" value="myvalue" />