{"id":19144400,"url":"https://github.com/maragudk/gomponents-htmx","last_synced_at":"2025-07-22T03:03:54.143Z","repository":{"id":81889371,"uuid":"605979708","full_name":"maragudk/gomponents-htmx","owner":"maragudk","description":"HTMX attributes and helpers for gomponents.","archived":false,"fork":false,"pushed_at":"2024-10-11T08:56:15.000Z","size":259,"stargazers_count":107,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-18T12:59:32.412Z","etag":null,"topics":["go","golang","gomponents","htmx"],"latest_commit_sha":null,"homepage":"https://www.gomponents.com/plus/#htmx","language":"Go","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/maragudk.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-24T10:20:49.000Z","updated_at":"2025-06-20T21:51:38.000Z","dependencies_parsed_at":"2024-06-19T16:02:53.802Z","dependency_job_id":"5e2a741b-7d37-4de4-9fe7-f1babf1ac027","html_url":"https://github.com/maragudk/gomponents-htmx","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":"maragudk/template","purl":"pkg:github/maragudk/gomponents-htmx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maragudk%2Fgomponents-htmx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maragudk%2Fgomponents-htmx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maragudk%2Fgomponents-htmx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maragudk%2Fgomponents-htmx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maragudk","download_url":"https://codeload.github.com/maragudk/gomponents-htmx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maragudk%2Fgomponents-htmx/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266416996,"owners_count":23925299,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"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":["go","golang","gomponents","htmx"],"created_at":"2024-11-09T07:34:47.386Z","updated_at":"2025-07-22T03:03:54.106Z","avatar_url":"https://github.com/maragudk.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gomponents-htmx\n\n\u003cimg src=\"logo.png\" alt=\"Logo\" width=\"300\" align=\"right\"\u003e\n\n[![GoDoc](https://pkg.go.dev/badge/maragu.dev/gomponents-htmx)](https://pkg.go.dev/maragu.dev/gomponents-htmx)\n[![CI](https://github.com/maragudk/gomponents-htmx/actions/workflows/ci.yml/badge.svg)](https://github.com/maragudk/gomponents-htmx/actions/workflows/ci.yml)\n\n[HTMX](https://htmx.org) attributes and helpers for [gomponents](https://www.gomponents.com).\n\nMade with ✨sparkles✨ by [maragu](https://www.maragu.dev/).\n\nDoes your company depend on this project? [Contact me at markus@maragu.dk](mailto:markus@maragu.dk?Subject=Supporting%20your%20project) to discuss options for a one-time or recurring invoice to ensure its continued thriving.\n\n## Usage\n\n```shell\ngo get maragu.dev/gomponents-htmx\n```\n\n```go\npackage main\n\nimport (\n\t\"errors\"\n\t\"log\"\n\t\"net/http\"\n\t\"time\"\n\n\t. \"maragu.dev/gomponents\"\n\t. \"maragu.dev/gomponents/components\"\n\t. \"maragu.dev/gomponents/html\"\n\t. \"maragu.dev/gomponents/http\"\n\n\thx \"maragu.dev/gomponents-htmx\"\n\thxhttp \"maragu.dev/gomponents-htmx/http\"\n)\n\nfunc main() {\n\tif err := start(); err != nil {\n\t\tlog.Fatalln(\"Error:\", err)\n\t}\n}\n\nfunc start() error {\n\tnow := time.Now()\n\tmux := http.NewServeMux()\n\tmux.HandleFunc(\"/\", Adapt(func(w http.ResponseWriter, r *http.Request) (Node, error) {\n\t\tif r.Method == http.MethodPost \u0026\u0026 hxhttp.IsBoosted(r.Header) {\n\t\t\tnow = time.Now()\n\n\t\t\thxhttp.SetPushURL(w.Header(), \"/?time=\"+now.Format(timeOnly))\n\n\t\t\treturn partial(now), nil\n\t\t}\n\t\treturn page(now), nil\n\t}))\n\n\tlog.Println(\"Starting on http://localhost:8080\")\n\tif err := http.ListenAndServe(\"localhost:8080\", mux); err != nil \u0026\u0026 !errors.Is(err, http.ErrServerClosed) {\n\t\treturn err\n\t}\n\treturn nil\n}\n\nconst timeOnly = \"15:04:05\"\n\nfunc page(now time.Time) Node {\n\treturn HTML5(HTML5Props{\n\t\tTitle: now.Format(timeOnly),\n\n\t\tHead: []Node{\n\t\t\tScript(Src(\"https://cdn.tailwindcss.com?plugins=forms,typography\")),\n\t\t\tScript(Src(\"https://unpkg.com/htmx.org\")),\n\t\t},\n\n\t\tBody: []Node{\n\t\t\tDiv(Class(\"max-w-7xl mx-auto p-4 prose lg:prose-lg xl:prose-xl\"),\n\t\t\t\tH1(Text(`gomponents + HTMX`)),\n\n\t\t\t\tP(Textf(`Time at last full page refresh was %v.`, now.Format(timeOnly))),\n\n\t\t\t\tpartial(now),\n\n\t\t\t\tForm(Method(\"post\"), Action(\"/\"),\n\t\t\t\t\thx.Boost(\"true\"), hx.Target(\"#partial\"), hx.Swap(\"outerHTML\"),\n\n\t\t\t\t\tButton(Type(\"submit\"), Text(`Update time`),\n\t\t\t\t\t\tClass(\"rounded-md border border-transparent bg-orange-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-orange-700 focus:outline-none focus:ring-2 focus:ring-orange-500 focus:ring-offset-2\"),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t),\n\t\t},\n\t})\n}\n\nfunc partial(now time.Time) Node {\n\treturn P(ID(\"partial\"), Textf(`Time was last updated at %v.`, now.Format(timeOnly)))\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaragudk%2Fgomponents-htmx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaragudk%2Fgomponents-htmx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaragudk%2Fgomponents-htmx/lists"}