{"id":20314563,"url":"https://github.com/dashpilot/data-to-div","last_synced_at":"2025-06-22T00:38:36.548Z","repository":{"id":191025927,"uuid":"683789892","full_name":"dashpilot/data-to-div","owner":"dashpilot","description":null,"archived":false,"fork":false,"pushed_at":"2023-08-27T18:36:37.000Z","size":1757,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-15T02:06:33.206Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dashpilot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-08-27T17:48:04.000Z","updated_at":"2023-08-27T17:48:12.000Z","dependencies_parsed_at":"2023-08-27T19:03:28.084Z","dependency_job_id":"a1ded08f-48d5-4f86-a73d-0a887e4bbb02","html_url":"https://github.com/dashpilot/data-to-div","commit_stats":null,"previous_names":["dashpilot/data-to-div"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dashpilot%2Fdata-to-div","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dashpilot%2Fdata-to-div/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dashpilot%2Fdata-to-div/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dashpilot%2Fdata-to-div/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dashpilot","download_url":"https://codeload.github.com/dashpilot/data-to-div/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241818857,"owners_count":20025210,"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-11-14T18:15:52.139Z","updated_at":"2025-03-04T08:44:09.187Z","avatar_url":"https://github.com/dashpilot.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"```\nnpm install data-to-div\n```\n\n# Data to div\n\nDataToDiv automatically generates html based on a data object. What's more: it can also generate data based on html that was previously generateed with DataToDiv :-) This can be useful for quick prototyping or even an on-page cms (if you change the html contents on the page, you can later convert it back to data to save the changes!).\n\n## SSR and CSR\n\nThis module supports both server-side rendering and client-side rendering, so you could just supply data and generate HTML pages on the server, than allow the user to make changes and rteurn the data (client-side).\n\n## How does it work?\n\nrun.js contains a demo, but here's the rundown:\n\n### toDiv\ntoDiv converts the data to HTML\n\n```js\n// import the module\nimport {toDiv, toData} from \"./index.js\"\nimport * as fs from \"fs\"\n\nif (!fs.existsSync('./public')){\n    fs.mkdirSync('./public');\n}\n\n// provide the data\nconst data = {\n    \"intro\": {\n    \"title\": \"Hello world\",\n    \"body\": \"Lorem ipsum dolor site amet\",\n    },\n    \"posts\": [{\"title\":\"First post\", \"body\":\"Lulala\"}, {\"title\":\"Second post\", \"body\":\"Lorem lala\"}]\n  };\n\n// the config object allows you to map html tags to keys in the data\nconst config = {\n    \"title\": \"h1\",\n    \"body\": \"p\",\n}\n\n// run it\nvar html = toDiv(data, config);\n\n// return the generated html\nconsole.log(html);\n\n```\n\n### toData\ntoData converts the HTML back to data\n\n```js\nconsole.log(JSON.stringify(toData(html)));\n\n```\n\n## Press the :star: button\nDon't forget to press the :star: button to let me know I should continue improving this project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdashpilot%2Fdata-to-div","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdashpilot%2Fdata-to-div","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdashpilot%2Fdata-to-div/lists"}