{"id":18376779,"url":"https://github.com/hcodes/jstohtml","last_synced_at":"2025-04-06T20:31:36.243Z","repository":{"id":20338705,"uuid":"23613265","full_name":"hcodes/jstohtml","owner":"hcodes","description":"Render HTML using JavaScript objects","archived":false,"fork":false,"pushed_at":"2023-01-08T15:10:21.000Z","size":716,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-22T06:51:15.108Z","etag":null,"topics":["html-template","javascript","nodejs"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/jstohtml","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/hcodes.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","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":"2014-09-03T08:52:05.000Z","updated_at":"2022-06-24T09:56:36.000Z","dependencies_parsed_at":"2023-01-13T20:55:13.136Z","dependency_job_id":null,"html_url":"https://github.com/hcodes/jstohtml","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hcodes%2Fjstohtml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hcodes%2Fjstohtml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hcodes%2Fjstohtml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hcodes%2Fjstohtml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hcodes","download_url":"https://codeload.github.com/hcodes/jstohtml/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247547555,"owners_count":20956572,"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":["html-template","javascript","nodejs"],"created_at":"2024-11-06T00:24:44.309Z","updated_at":"2025-04-06T20:31:35.816Z","avatar_url":"https://github.com/hcodes.png","language":"JavaScript","readme":"jstohtml\n========\n[![NPM version](https://img.shields.io/npm/v/jstohtml.svg?style=flat)](https://www.npmjs.com/package/jstohtml)\n[![NPM downloads](https://img.shields.io/npm/dm/jstohtml.svg?style=flat)](https://www.npmjs.com/package/jstohtml)\n[![bundlephobia](https://badgen.net/bundlephobia/minzip/jstohtml)](https://bundlephobia.com/result?p=jstohtml)\n[![install size](https://packagephobia.com/badge?p=jstohtml)](https://packagephobia.com/result?p=jstohtml)\n\nCompact record format HTML at JavaScript.\n\n## Usage\n### Browser\n```HTML\n\u003cscript src=\"node_modules/jstohtml/dist/jstohtml.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n    console.log(jstohtml({c: 'Hello world!'}));\n    // \u003cdiv\u003e\u003cHello world!\u003c/div\u003e\n\u003c/script\u003e\n```\n### Node.js\n```\nnpm install jstohtml --save-dev\n```\n\n```js\nimport jstohtml from 'jstohtml';\nconsole.log(jstohtml({c: 'Hello world!'}));\n```\n\n## Examples\n\n### Elementary\n| Input      | Output |\n| ----------- | ----------- |\n|`jstohtml('Hello world!');`|`Hello world!`|\n|`jstohtml({});`|`\u003cdiv\u003e\u003c/div\u003e`|\n|`jstohtml({cl: 'main'});`|`\u003cdiv class=\"main\"\u003e\u003c/div\u003e`|\n|`jstohtml({cl: ['main', 'red']});`|`\u003cdiv class=\"main red\"\u003e\u003c/div\u003e`|\n|`jstohtml({title: 'My title', 'data-a': 123, style: 'font-size: 2em'});`|`\u003cdiv title=\"My title\" data-a=\"123\" style=\"font-size: 2em\"\u003e\u003c/div\u003e`|\n|`jstohtml({t: 'p', cl: ['main', 'red'], c: 'Content'});`|`\u003cp class=\"main red\"\u003eContent\u003c/p\u003e`|\n|`jstohtml([]);`| |\n|`jstohtml([{}, {}]);`|`\u003cdiv\u003e\u003c/div\u003e\u003cdiv\u003e\u003c/div\u003e`|\n|`jstohtml([{c: {c: 'Content'}}]);`|`\u003cdiv\u003e\u003cdiv\u003eContent\u003c/div\u003e\u003c/div\u003e`|\n|`jstohtml([{c: [{c: 'Content1'}, {c: 'Content2'}] }]);`|`\u003cdiv\u003e\u003cdiv\u003eContent1\u003c/div\u003e\u003cdiv\u003eContent2\u003c/div\u003e\u003c/div\u003e`|\n\n### BEM\n| Input      | Output |\n| ----------- | ----------- |\n|`jstohtml({b: 'example'}); // block`|`\u003cdiv class=\"example\"\u003e\u003c/div\u003e`|\n|`jstohtml({b: 'example', e: 'elem'}); // block, elem`|`\u003cdiv class=\"example__elem\"\u003e\u003c/div\u003e`|\n|`jstohtml({b: 'example', m: {a: true, b: 'val'}}); // block, mod`|`\u003cdiv class=\"example example_a example_b_val\"\u003e\u003c/div\u003e`|\n|`jstohtml({b: 'example', e: 'elem', m: {a: true, b: 'val'}}); // block, elem, mod`|`\u003cdiv class=\"example__elem example__elem_a example__elem_b_val\"\u003e\u003c/div\u003e`|\n\n### Complex\n```JavaScript\njstohtml([\n    {\n        c: 'Menu:'\n    },\n    {\n        t: 'ul', // tag\n        cl: ['menu', 'menu_theme-normal'], // class attribute\n        c: [ // content or children\n            {\n                t: 'li',\n                cl: 'menu-option',\n                title: '1', // attribute\n                'data-first': 'yes', // data attribute\n                //...\n                c: '1'\n            }, {\n                t: 'li',\n                cl: 'menu-option',\n                title: '2'\n                c: '2'\n            }, {\n                t: 'li',\n                cl: 'menu-option',\n                title: '3',\n                c: '3'\n            }\n        ]\n    }\n]);\n```\n\n```HTML\n\u003cdiv\u003eMenu:\u003c/div\u003e\n\u003cul class=\"menu menu_theme-normal\"\u003e\n    \u003cli class=\"menu-option\" title=\"1\" data-first=\"yes\"\u003e1\u003c/li\u003e\n    \u003cli class=\"menu-option\" title=\"2\"\u003e2\u003c/li\u003e\n    \u003cli class=\"menu-option\" title=\"3\"\u003e3\u003c/li\u003e\n\u003c/ul\u003e\n```\n\n\n## [License](./LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhcodes%2Fjstohtml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhcodes%2Fjstohtml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhcodes%2Fjstohtml/lists"}