{"id":14967787,"url":"https://github.com/lorefnon/pug2tsx","last_synced_at":"2025-10-25T21:32:01.825Z","repository":{"id":42633995,"uuid":"174831123","full_name":"lorefnon/pug2tsx","owner":"lorefnon","description":"Convert pug to TSX","archived":false,"fork":false,"pushed_at":"2023-10-18T15:13:42.000Z","size":2098,"stargazers_count":4,"open_issues_count":4,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-04T09:49:56.680Z","etag":null,"topics":["language","pug","react","typescript","user-interface"],"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/lorefnon.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":"2019-03-10T13:59:55.000Z","updated_at":"2023-02-25T14:42:01.000Z","dependencies_parsed_at":"2023-01-21T17:15:27.601Z","dependency_job_id":null,"html_url":"https://github.com/lorefnon/pug2tsx","commit_stats":null,"previous_names":["lorefnon/molosser"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lorefnon%2Fpug2tsx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lorefnon%2Fpug2tsx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lorefnon%2Fpug2tsx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lorefnon%2Fpug2tsx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lorefnon","download_url":"https://codeload.github.com/lorefnon/pug2tsx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238212440,"owners_count":19434955,"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":["language","pug","react","typescript","user-interface"],"created_at":"2024-09-24T13:38:36.370Z","updated_at":"2025-10-25T21:32:01.449Z","avatar_url":"https://github.com/lorefnon.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# About\n\nPug is a concise low-boilerplate templating language. It was originally designed for generating HTML strings.\n\nPug2tsx is a simple framework-agnostic utility that compiles pug templates to Typescript TSX files, enabling pug to be used for libraries like Solid.js \u0026 React in type-safe manner.\n\n## Usage\n\n```\npug2tsx -i \u003cinput-directory\u003e -o \u003coutput-directory\u003e\n```\n\nThis will generate typescript files in the `output-directory` which will have to be separately compiled\nthrough `tsc` or other typescript compatible bundler. Refer [typescript documentation](https://www.typescriptlang.org/docs/handbook/typescript-in-5-minutes.html) for other details.\n\n## Syntax\n\n```\n// hello.pug\n- import * as React from \"react\"\n\n- export const Hello = () =\u003e\n    div\n        | Hello world\n```\n\nThe above is compiled to:\n\n```\n// hello.tsx\n\nimport * as React from \"react\";\n\nexport const Hello = () =\u003e {\n    return (\n        \u003cdiv\u003e\n            Hello world\n        \u003c/div\u003e\n    );\n}\n```\n\n## Motivation\n\n- Due to popularity of React the JS ecosystem has settled on unweildy XML based syntax for component composition.\n- Pug/Haml/Slim's indented syntax is much cleaner and succint.\n- Solutions like [babel-plugin-transform-react-pug](https://github.com/pugjs/babel-plugin-transform-react-pug) are framework dependent (only React) and are not Typescript friendly.\n\n## Differences from primary Pug compiler\n\n1. Pug compiles to HTML/Javascript, Pug2tsx compiles to typescript code.\n1. Pug allows fragments of code which are not valid javascript and has some smart detection of blocks:\n   ```\n   - for (var x = 0; x \u003c 3; x++)\n     li item\n   ```\n   pug2tsx expects (and validates) code blocks to be valid typescript - so above usage is illegal.\n\n4. Following pug features are not supported, because they don't blend well with component oriented usage:\n   1. Includes/Extends/Blocks - Just use ES6 imports and Composition of components\n   2. Mixins - Use composition of components\n   3. Filters - May be implemented someday\n\n## TODO\n\n- [ ] Language server plugin\n- [ ] Webpack loader\n\n## Contributing\n\nContributions are welcome in form of bug reports and pull requests through [github](https://github.com/lorefnon/pug2tsx).\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Florefnon%2Fpug2tsx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Florefnon%2Fpug2tsx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Florefnon%2Fpug2tsx/lists"}