{"id":16527699,"url":"https://github.com/benoitzugmeyer/wisdom","last_synced_at":"2025-06-29T23:34:38.394Z","repository":{"id":3016471,"uuid":"4035817","full_name":"BenoitZugmeyer/Wisdom","owner":"BenoitZugmeyer","description":"A tiny API to build DOM","archived":false,"fork":false,"pushed_at":"2012-04-16T11:57:49.000Z","size":108,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-13T16:25:10.783Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BenoitZugmeyer.png","metadata":{"files":{"readme":"README.rst","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":"2012-04-15T23:04:18.000Z","updated_at":"2018-12-14T10:01:37.000Z","dependencies_parsed_at":"2022-08-26T03:41:48.405Z","dependency_job_id":null,"html_url":"https://github.com/BenoitZugmeyer/Wisdom","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/BenoitZugmeyer%2FWisdom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenoitZugmeyer%2FWisdom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenoitZugmeyer%2FWisdom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BenoitZugmeyer%2FWisdom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BenoitZugmeyer","download_url":"https://codeload.github.com/BenoitZugmeyer/Wisdom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241610990,"owners_count":19990508,"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-11T17:36:29.691Z","updated_at":"2025-03-03T05:14:23.513Z","avatar_url":"https://github.com/BenoitZugmeyer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Wisdom\n======\n\nWisdom is a tiny JavaScript library intended to simplify DOM construction. Its\ngoal is to be used in projects who does not use templates to format HTML.\n\n* Really small (≈ 1.1KB minified + gziped)\n\n* Compact and easy to use\n\n* Easy to read\n\n* Adaptable with any framework who does DOM manipulation\n\n\nDocumentation\n-------------\n\nAll methods have the same signature: they populate the current element (or the\nroot if there is no open element) by iterating over the passed arguments.\n\n* falsy arguments will be ignored,\n\n* DOM elements and objects with an ``inject`` method will be appended,\n\n* array-like (objects with a length) will be iterated and their values will\n  be used to populate the element (splat effect),\n\n* plain objects will be used to set attributes with the ``setter`` function,\n\n* other arguments will be used as strings and appended.\n\n\n``Wisdom(...)``\n............\n\nConstructor. Populate the root with its arguments. The ``new`` keyword is\noptionnal.\n\n``Wisdom:\u003ctagname\u003e(...)``\n..........................\n\nAppend an element to the parent and populate it with the arguments.\n``\u003ctagname\u003e`` can be any HTML element name.\n\n``Wisdom:$(...)``\n.................\n\n'Close' the current element and populate its parent with the arguments. The\nnext element will be appended next to the current element.\n\n``Wisdom:$$(...)``\n..................\n\nRecursively close all opened elements and populates the root with the\narguments. The next element will be appended in the root.\n\n``Wisdom:_(...)``\n.................\n\nSimply populates the current element with the arguments.\n\n``Wisdom:inject(domnode, ?where)``\n..................................\n\nInject the root in a DOM node. ``where`` can be either ``'bottom'`` (the\ndefault), ``'top'``, ``'after'`` or ``'before'``.\n\n``Wisdom:clean(...)``\n.....................\n\nEmpty the current root, so the instance is reusable (slightly quicker than\nrecreating a new instance). Populate the new root with the arguments.\n\n``Wisdom:last``\n...............\n\nReference to the current element. This is the element who will be used as\nparent for the next content appended. Use it to store DOM references in your\ncode.\n\n``Wisdom.defineSetter(nameOrSetter, ?setter)``\n..............................................\n\nDefine the current setter to use, and returns the old one.\n\nIf the first argument is a function, it is used to do some DOM manipulation\nbased on an object. The DOM element and the object to apply is passed as\narguments to the function.\n\nIf the first argument is a string and the second is a function, it defines a\n'named' setter, which is immediately defines the current setter and can be\nrestored by calling this static method with the name alone.\n\nIf the first argument is a string and no second argument is given, it defines\nthe current setter to the previously registered named setter.\n\n\nExample\n-------\n\n::\n\n  new Wisdom()\n    .h1('Hello World!').$()\n    .p('How are you today? did you check ')\n      .a('this awesome JS lib', { href: 'http://github.com/BenoitZugmeyer/Wisdom' })\n      .$(' which let you build your DOM insanely fast?')\n    .$()\n    .p('I hope you\\'ll like it!')\n    .inject(document.body);\n\nHTML equivalent:\n\n::\n\n  \u003ch1\u003eHello World!\u003c/h1\u003e\n  \u003cp\u003eHow are you today? did you check\n    \u003ca href=\"http://github.com/BenoitZugmeyer/Wisdom\"\u003ethis awesome JS lib\u003c/a\u003e\n    which let you build your DOM insanely fast?\n  \u003c/p\u003e\n  \u003cp\u003eI hope you'll like it!\u003c/p\u003e\n\nExample of usage using a MooTools setter:\n\n::\n\n  Wisdom.defineSetter(function (dom, object) {\n    document.id(dom).set(object);\n  });\n\n  new Wisdom()\n    .form({ events: { submit: function () { alert('submitted!'); } } }),\n      .label({ styles: { color: 'red' } }, 'Name:')\n        .input({ type: 'text' }).$()\n      .$()\n      .input({ type: 'submit' }, 'Send').$()\n    .inject(document.body);\n\n\nToDo\n----\n\n* More examples\n\n* Benchmarks (vs template engines, plain innerHTML, DOM creation using popular frameworks)\n\n\nLicense\n-------\n\nThis library is relaesed under a MIT license. See the file LICENSE.txt for the\nfull content of the license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenoitzugmeyer%2Fwisdom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenoitzugmeyer%2Fwisdom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenoitzugmeyer%2Fwisdom/lists"}