{"id":23109985,"url":"https://github.com/tareqk/j2htmx","last_synced_at":"2025-08-16T18:33:08.483Z","repository":{"id":60520629,"uuid":"526692215","full_name":"TareqK/j2htmx","owner":"TareqK","description":"htmx and hyperscript extentions for j2html","archived":false,"fork":false,"pushed_at":"2022-08-28T18:38:36.000Z","size":37,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-23T02:25:40.329Z","etag":null,"topics":["hateoas","html-generation","htmx","restful","web"],"latest_commit_sha":null,"homepage":"","language":"Java","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/TareqK.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":"2022-08-19T17:15:36.000Z","updated_at":"2023-12-20T22:24:42.000Z","dependencies_parsed_at":"2022-09-30T19:40:17.062Z","dependency_job_id":null,"html_url":"https://github.com/TareqK/j2htmx","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TareqK%2Fj2htmx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TareqK%2Fj2htmx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TareqK%2Fj2htmx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TareqK%2Fj2htmx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TareqK","download_url":"https://codeload.github.com/TareqK/j2htmx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230050241,"owners_count":18165033,"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":["hateoas","html-generation","htmx","restful","web"],"created_at":"2024-12-17T01:47:33.158Z","updated_at":"2024-12-17T01:47:33.829Z","avatar_url":"https://github.com/TareqK.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# J2Htmx\n\n[![Maven Central Badge](https://img.shields.io/maven-central/v/me.kisoft/j2htmx)](https://search.maven.org/artifact/me.kisoft/j2htmx)\n[![Discord](https://img.shields.io/discord/725789699527933952)](https://htmx.org/discord)\n\nJ2htmx is a set of extentions for [j2html](https://j2html.com/) to make it work better with [htmx](https://htmx.org/) attributes and\n[hyperscript](https://hyperscript.org/)\n\n## Usage\n\nImport the latest version of the library from maven central\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003eme.kisoft\u003c/groupId\u003e\n  \u003cartifactId\u003ej2htmx\u003c/artifactId\u003e\n  \u003cversion\u003e2.0.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nAfterwards, either import the htmx scripts from CDN yourself or use the ``withHtmxImports`` function on a ``ContainerTag``, which \nshould ideally be your ``head`` tag\n\n\n```java\nhtml(\n    withHtmxImport(\n        head()\n    ),\n    body(/* stuff goes here */)\n)\n\n```\n\nafterwards, you can use any of the htmx attributes using the ``hx`` static import, such as \n\n```java\ndiv(\n    div().withId(\"my-id\"),\n    button().withText(\"Click for a new Joke\")\n        .attr(hx.get(\"/my-path\")\n        .attr(hx.target(\"#my-id\")\n    )\n)\n```\n\nAll htmx attributes are supported. You can find them all [here](https://htmx.org/reference/)\n\n\n### Attribute Generators\n\nThere is a convinience method, for generating attributes, allowing you to generate\nattributes as a functional interface or class. This allows you to create re-usable \nattribute generators to use across components.\n\n```java\ndiv(\n    div().withId(\"my-id\"),\n    button().withText(\"Click for a new Joke\")\n        .attr(hx.get(\"/my-path\")\n        .attr(hx.target(()-\u003e\"#my-id\")\n    )\n)\n```\n\nWhile they make a small difference in most cases, this allows us to more easily \nuse random Ids and reusable attributes.\n\n\n### Hyperscript support\n\nYou can use the ``withHyperscriptImport`` function to import hyperscript as well\n\n```java\nhtml(\n    withHyperscriptImport(\n        withHtmxImport(\n            head()\n        )\n    ),\n    body(/* stuff goes here */)\n)\n```\n\nThere is a ``hx.hyperscript`` method that you can use to add hyperscript to any\ntag. you can find more about hyperscript [here](https://hyperscript.org/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftareqk%2Fj2htmx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftareqk%2Fj2htmx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftareqk%2Fj2htmx/lists"}