{"id":18096237,"url":"https://github.com/bredele/grout","last_synced_at":"2026-07-23T16:31:36.970Z","repository":{"id":26181423,"uuid":"29627211","full_name":"bredele/grout","owner":"bredele","description":":sweat_drops: virtual dom","archived":false,"fork":false,"pushed_at":"2015-12-09T05:54:33.000Z","size":41,"stargazers_count":3,"open_issues_count":23,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-14T09:16:59.728Z","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/bredele.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-21T23:17:04.000Z","updated_at":"2016-02-04T21:30:19.000Z","dependencies_parsed_at":"2022-07-27T07:16:56.251Z","dependency_job_id":null,"html_url":"https://github.com/bredele/grout","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/bredele%2Fgrout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bredele%2Fgrout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bredele%2Fgrout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bredele%2Fgrout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bredele","download_url":"https://codeload.github.com/bredele/grout/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247428614,"owners_count":20937506,"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-31T19:13:05.559Z","updated_at":"2026-07-23T16:31:36.953Z","avatar_url":"https://github.com/bredele.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# grout\n\nGrout is a declarative way to create DOM elements and efficiently update them whenever data changes. Also called virtual-dom it is the perfect companion for [brick](http://github.com/brickjs) and also works server side with nodejs.\n\n```js\nvar inception = dom('ul', [\n  dom('li', 'Hello'),\n  dom('li', '${name}')\n]);\n\ninception({\n  name: 'bredele'\n});\n```\n[see live]()\n\nBoth [brick](http://github.com/brickjs) and grout promote clean and maintainable rendering logic. Their speed as well as their combined weight (only 3kb) makes them ideal for desktop and mobile. \n\n## Learn it in 3\n\n### create\n\nCreate a DOM element\n\n```js\nvar btn = dom('button');\nbtn();\n// =\u003e \u003cbutton\u003e\u003c/button\u003e\n```\n\nwith a text content\n\n```js\nvar btn = dom('button', 'Hello world!');\nbtn();\n// =\u003e \u003cbutton\u003eHello world!\u003c/button\u003e\n```\n\nand quickly append multiple DOM nodes.\n\n```js\nvar inception = dom('ul', [\n  dom('li', 'first item'),\n  dom('li', 'second item')\n]);\ninception();\n```\n\nGrout keeps manual DOM manipulation out of your application code.\n\n### attributes\n\nCreate attributes \n\n```js\nvar btn = dom('button', null, {\n  id: 'btn',\n  class: 'dark'\n});\nbtn();\n// =\u003e \u003cbutton id=\"btn\" class=\"dark\"\u003e\u003c/button\u003e\n```\n\nadd some inline styles\n\n```js\nvar btn = dom('button', null, {\n  id: 'btn',\n  style: {\n    background: 'red'\n  }\n});\nbtn();\n// =\u003e \u003cbutton id=\"btn\" class=\"dark\"\u003e\u003c/button\u003e\n```\n\n\nand attach event listeners\n\n```js\nvar btn = dom('button', null, {\n  id: 'btn',\n  onclick: function() {\n    // do something\n  }\n});\nbtn();\n```\nit is that easy!\n\n### observable\n\nBind a DOM element with some data\n\n```js\nvar btn = dom('button', 'Hello ${name}!');\nbtn({\n  name: 'bredele'\n});\n// =\u003e \u003cbutton\u003eHello bredele\u003c/button\u003e\n```\n\nand update it whenever the data changes\n\n```js\nbtn({\n  name: 'olivier'\n});\n// =\u003e \u003cbutton\u003eHello olivier\u003c/button\u003e\n```\n\nIt is blazing fast and works with every DOM nodes\n\n```js\nvar btn = dom('button', 'Hello ${name}', {\n  class: '${type}'\n});\n\nbtn({\n  name: 'olivier',\n  type: 'developer'\n});\n// =\u003e \u003cbutton class=\"developer\"\u003eHello olivier\u003c/button\u003e\n```\n\n## Advanced\n\n### Use with [datastore](http://github.com/bredele/datastore)\n\n```js\nvar store = new Store();\n\nvar btn = dom('button', '${name}');\nbtn(store);\n\nstore.set('name', 'bredele');\n// =\u003e \u003cbutton\u003ebredele\u003c/button\u003e\n\nstore.set('name', 'olivier');\n// =\u003e \u003cbutton\u003eolivier\u003c/button\u003e\n```\n\n### Use with [brick](http://github.com/bredele/brickjs)\n\n```js\nvar list = brick(\n  dom('ul', [\n    dom('li', 'hello ${name}'),\n    dom('li', [\n      dom('button', 'welcome!', {\n        class: 'btn ${repo}'\n      })\n    ])\n  ])\n);\n\nlist.set({\n  name: 'olivier',\n  repo: 'grout'\n});\n```\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2014 Olivier Wietrich \u003colivier.wietrich@gmail.com\u003e\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbredele%2Fgrout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbredele%2Fgrout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbredele%2Fgrout/lists"}