{"id":16370851,"url":"https://github.com/integralist/dom-builder","last_synced_at":"2025-10-26T07:32:09.055Z","repository":{"id":7351407,"uuid":"8675438","full_name":"Integralist/DOM-Builder","owner":"Integralist","description":"Small utility script for easily generating a DOM structure","archived":false,"fork":false,"pushed_at":"2013-08-16T15:35:34.000Z","size":99,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-31T16:55:24.398Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Integralist.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-03-09T20:10:00.000Z","updated_at":"2025-01-22T20:09:45.000Z","dependencies_parsed_at":"2022-08-26T22:52:49.735Z","dependency_job_id":null,"html_url":"https://github.com/Integralist/DOM-Builder","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Integralist%2FDOM-Builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Integralist%2FDOM-Builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Integralist%2FDOM-Builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Integralist%2FDOM-Builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Integralist","download_url":"https://codeload.github.com/Integralist/DOM-Builder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238284946,"owners_count":19446766,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T03:06:15.698Z","updated_at":"2025-10-26T07:32:03.820Z","avatar_url":"https://github.com/Integralist.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"DOM-Builder\n===========\n\nSmall utility script for easily generating a DOM structure.\n\nThe library is ~52 lines of code.\n\nThe size is ~710 bytes when run through the uglify js minifier (and even smaller once gzip'ed)\n\nAMD compatible (see [index-amd.html](index-amd.html)).\n\n##Example\n\n```js\n// Returns DOM structure as a document fragment\nvar structure = DOM.init(\n    DOM.create('div#js-a').content(\n        DOM.create('p').content('abc'),\n        DOM.create('p').content('def')\n    ),\n    DOM.create('div#js-b.x.y.z').content(\n        DOM.create('p#js-c.some_other_class').content('ghi')\n    ),\n    DOM.create('select').content(\n        DOM.create('option[value=1][data-test=123]').content('Hah!')\n    )\n);\n\ndocument.body.appendChild(structure);\n```\n\n##Alias\n\nYou can also use `DOM.el` if you wanted to instead of `DOM.create`:\n\n```js\nvar structure = DOM.init(\n    DOM.el('div#js-a').content(\n        DOM.el('p').content('abc'),\n        DOM.el('p').content('def')\n    ),\n    DOM.create('div#js-b.x.y.z').content(\n        DOM.el('p#js-c.some_other_class').content('ghi')\n    )\n);\n```\n\n##AMD\n\nYou can use an AMD loader such as [RequireJS](http://www.requirejs.org/) to load the DOM Builder script:\n\n```js\n// module_dombuilder.js\ndefine(['dombuilder'], function($) {\n    var structure = $.init(\n        $.create('div#js-a').content(\n            $.create('p').content('abc'),\n            $.create('p').content('def')\n        ),\n        $.create('div#js-b.x.y.z').content(\n            $.create('p#js-c.some_other_class').content('ghi')\n        )\n    );\n\n    var structure_alias = $.init(\n        $.el('div#js-x').content(\n            $.el('p').content('123'),\n            $.el('p').content('456')\n        ),\n        $.el('div#js-y.a.b.c').content(\n            $.el('p#js-z.some_other_class').content('789')\n        )\n    );\n});\n\n// Application.js\nrequire(['module_dombuilder', 'module_x', 'module_y', 'module_z']);\n```\n\n##Note\n\nDo not use `DOM.create` or `DOM.el` outside of a `DOM.init` call as they wont function as intended. The way DOM Builder has been built is to allow the return value from those functions to be passed into `DOM.init` to handle.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintegralist%2Fdom-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fintegralist%2Fdom-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintegralist%2Fdom-builder/lists"}