{"id":21961860,"url":"https://github.com/trapcodeio/j2ht","last_synced_at":"2026-02-26T17:49:04.914Z","repository":{"id":57278923,"uuid":"292042440","full_name":"trapcodeio/j2ht","owner":"trapcodeio","description":"A javascript to html Template Engine","archived":false,"fork":false,"pushed_at":"2021-11-13T19:44:44.000Z","size":37,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-30T08:56:44.451Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/trapcodeio.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}},"created_at":"2020-09-01T15:55:34.000Z","updated_at":"2023-01-14T13:05:10.000Z","dependencies_parsed_at":"2022-09-11T18:12:32.740Z","dependency_job_id":null,"html_url":"https://github.com/trapcodeio/j2ht","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/trapcodeio/j2ht","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapcodeio%2Fj2ht","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapcodeio%2Fj2ht/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapcodeio%2Fj2ht/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapcodeio%2Fj2ht/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trapcodeio","download_url":"https://codeload.github.com/trapcodeio/j2ht/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trapcodeio%2Fj2ht/sbom","scorecard":{"id":897213,"data":{"date":"2025-08-11","repo":{"name":"github.com/trapcodeio/j2ht","commit":"b0353d9456012b59b6da3f962ca3562a664eda42"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-24T14:10:36.107Z","repository_id":57278923,"created_at":"2025-08-24T14:10:36.107Z","updated_at":"2025-08-24T14:10:36.107Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29867060,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-26T16:38:37.846Z","status":"ssl_error","status_checked_at":"2026-02-26T16:37:58.932Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-29T10:19:22.127Z","updated_at":"2026-02-26T17:49:04.894Z","avatar_url":"https://github.com/trapcodeio.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# J2ht (Under Development)\n\nJ2ht is a **Javascript to html template Engine**\n\nThe idea came when I stumbled upon this library [html-creator](https://www.npmjs.com/package/html-creator), and before\nthen i have always wanted to **extend** html without using any template engine just some codes, and I ended up with a\ntemplate engine lol.\n\nIt may feel weird when you think about it but I find it kinda fun and hope you do too.\n\n## Installation\n\n### Npm\n\n```shell script\nnpm i j2ht\n```\n\n### Yarn\n\n```shell script\nyarn add j2ht\n```\n\n## Demo\n\nIf you clone this repo there are some examples you can examine using your I.D.E\n\n* `npm run test:basic`  - A basic console example\n* `npm run test:server`  - A server example using [Xpresser](https://www.npmjs.com/package/xpresser)\n* `npm run test:merge`  - An example showing how to import views and merge them.\n\n## Basic Usage\n\n```javascript\nconst {pretty, RawHtml, Elements} = require('j2ht');\nconst {Doctype, Html, Head, Title, Body, H2, H5} = require('j2ht/js/elements');\n\nconst user = 'paul';\n\nconst template = Elements(\n    Doctype(),\n    Html(\n        Head(Title('My First App')),\n        Body(\n            H2('Hello World'),\n            RawHtml(`\u003ch5\u003eA message from RawHtml\u003c/h5\u003e`),\n            \n            // Conditional views. \n            user === 'paul' ?\n                H5('Hey Paul 👋') : H5('Hey unknown user! 😏')\n        ),\n    )\n)\n\nconsole.log(pretty(template));\n```\n\nThis will return\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eMy First App\u003c/title\u003e\n  \u003c/head\u003e\n\n  \u003cbody\u003e\n    \u003ch2\u003eHello World\u003c/h2\u003e\n    \u003ch5\u003eA message from RawHtml\u003c/h5\u003e\n    \u003ch5\u003eHey Paul 👋\u003c/h5\u003e\n  \u003c/body\u003e\n\n\u003c/html\u003e\n```\n\n### For Merging Views only\n\nFile Structure\n\n```\n-html\n    -footer.html\n    -header.html\n    -Home.html\napp.js\n```\n\n**app.js**\n\n```javascript\nconst {pretty, Elements, FromFile} = require('j2ht');\n\nconst template2 = Elements(\n    FromFile(__dirname + '/html/header.html'),\n    FromFile(__dirname + '/html/Home.html'),\n    FromFile(__dirname + '/html/footer.html'),\n)\n\nconsole.log(pretty(template2));\n```\n\n## Elements\n\nFor now only few html elements are out of the box. i will add new ones in the near future. But adding yours is not\ndifficult.\n\nif you take a look at the `elements.ts` file you can see how default elements are created.\n\u003cbr/\u003e For example `\u003cdiv\u003e` was created using the following line\n\n```javascript\nconst {HtmlElement} = require('j2ht');\nexports.Div = (...contents) =\u003e new HtmlElement('div').content(contents);\n\n// To create a table element\nexports.Table = (...contents) =\u003e new HtmlElement('table').content(contents);\n```\n\nEvery `HtmlElement` instance has a `render()` method that builds it and returns html data\n\n```javascript\nconst {Div, H1} = require('j2ht/js/elements');\n\nconst component = Div(H1('Hello World'))\n\nconsole.log(component.render());\n```\n\nCalling `.render()` will render and return\n\n```html\n\n\u003cdiv\u003e\u003ch1\u003eHello World\u003c/h1\u003e\u003c/div\u003e\n```\n\n## Components\n\nj2ht being javascript can be easily extendable.\n\nLets make a bulma buttons component `bulma-buttons.js`\n\n```javascript\nconst {Button} = require('j2ht/js/elements');\n\nexports.PrimaryButton = (...content) =\u003e Button(...content).class('button is-primary');\nexports.SuccessButton = (...content) =\u003e Button(...content).class('button is-success');\n```\n\nNotice how we always use spread operators? this is because of the syntax concept where Elements are functions, and their\narguments are child contents.\n\n```javascript\nconst {Div} = require('j2ht/js/elements');\nconst {PrimaryButton, SuccessButton} = require('./bulma-buttons');\n\nDiv(\n    PrimaryButton('Save'),\n    SuccessButton('Cancel')\n)\n```\n\n`Div` is a function while it's children are arguments. you can also pass them as an array.\n\n```javascript\nDiv([\n    PrimaryButton('Save'),\n    SuccessButton('Cancel')\n])\n```\n\nBoth will render\n\n```html\n\u003cdiv\u003e\n    \u003cbutton class=\"button is-primary\"\u003eSave\u003c/button\u003e\n    \u003cbutton class=\"button is-danger\"\u003eCancel\u003c/button\u003e\n\u003c/div\u003e\n```\n\nI will keep adding more features and maybe along the line i will find more use for it.\n\u003cbr/\u003e\nFeel free to contribute if you like this project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrapcodeio%2Fj2ht","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrapcodeio%2Fj2ht","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrapcodeio%2Fj2ht/lists"}