From 49db0474123369b9004df3a26e82c66a71b654a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tanguy=20=E2=A7=93=20Herrmann?= Date: Wed, 15 Oct 2025 17:06:24 +0200 Subject: [PATCH 1/5] fix: add doctype to page templates --- encoding/html/templates/entity_page.gotpl | 1 + examples/html-template/templates/entity_page.gotpl | 1 + 2 files changed, 2 insertions(+) diff --git a/encoding/html/templates/entity_page.gotpl b/encoding/html/templates/entity_page.gotpl index 2a5c5c9..4f272ef 100644 --- a/encoding/html/templates/entity_page.gotpl +++ b/encoding/html/templates/entity_page.gotpl @@ -1,4 +1,5 @@ {{ define "entity_page" }} + {{ template "entity_header" }} diff --git a/examples/html-template/templates/entity_page.gotpl b/examples/html-template/templates/entity_page.gotpl index 2a5c5c9..4f272ef 100644 --- a/examples/html-template/templates/entity_page.gotpl +++ b/examples/html-template/templates/entity_page.gotpl @@ -1,4 +1,5 @@ {{ define "entity_page" }} + {{ template "entity_header" }} From b8250394403e890dddc184ddebb2d12c4d69b629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tanguy=20=E2=A7=93=20Herrmann?= Date: Wed, 15 Oct 2025 17:09:39 +0200 Subject: [PATCH 2/5] fix: use idField helper for getting ID --- examples/html-template/templates/entity.gotpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/html-template/templates/entity.gotpl b/examples/html-template/templates/entity.gotpl index 12133f5..8127b6f 100644 --- a/examples/html-template/templates/entity.gotpl +++ b/examples/html-template/templates/entity.gotpl @@ -3,7 +3,7 @@ {{ with .Entity }}

-

+
{{- range $v := .Fields }} {{ if eq $v.Key "ID" }}
: {{ $v.Value }}
From 51ad11366a4a6258852909c3ac385ddaefdd90e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tanguy=20=E2=A7=93=20Herrmann?= Date: Wed, 15 Oct 2025 17:11:04 +0200 Subject: [PATCH 3/5] feat: add pico.css --- .../html-template/templates/entity_header.gotpl | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/examples/html-template/templates/entity_header.gotpl b/examples/html-template/templates/entity_header.gotpl index 38bcaf1..4562fd6 100644 --- a/examples/html-template/templates/entity_header.gotpl +++ b/examples/html-template/templates/entity_header.gotpl @@ -1,16 +1,8 @@ {{ define "entity_header" }} + + - {{ end }} From 58e347cacae97e0f8f2a0d4f9d7cfe96997cbb98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tanguy=20=E2=A7=93=20Herrmann?= Date: Wed, 15 Oct 2025 17:12:13 +0200 Subject: [PATCH 4/5] fix: convert all ID to string --- examples/html-template/templates/entity_form.gotpl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/html-template/templates/entity_form.gotpl b/examples/html-template/templates/entity_form.gotpl index 5a9721f..7c12115 100644 --- a/examples/html-template/templates/entity_form.gotpl +++ b/examples/html-template/templates/entity_form.gotpl @@ -2,12 +2,13 @@ {{ $pathPrefix := .PathPrefix }} {{ $method := "put" }} {{ with .Entity }} + {{ $id := (.ID | toString) }} - {{ if eq .ID 0 }} + {{ if eq $id "" }} {{ $method = "post" }} -
+ {{ else }} - + {{ end }} {{- range $f := .Fields }} {{ if ne $f.Key "ID" }} @@ -26,7 +27,7 @@ {{- end }} - +
{{ end }} {{ end }} From 3cadcd3e1ebc0d3e14393639b3d4a66a79aac94b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tanguy=20=E2=A7=93=20Herrmann?= Date: Wed, 15 Oct 2025 17:12:54 +0200 Subject: [PATCH 5/5] feat: improve semantic HTML --- examples/html-template/templates/entity.gotpl | 11 ++++++---- .../html-template/templates/entity_form.gotpl | 21 ++++++++++--------- .../templates/entity_form_page.gotpl | 4 +++- .../html-template/templates/entity_list.gotpl | 21 ++++++++++++------- .../html-template/templates/entity_page.gotpl | 10 +++++++-- 5 files changed, 43 insertions(+), 24 deletions(-) diff --git a/examples/html-template/templates/entity.gotpl b/examples/html-template/templates/entity.gotpl index 8127b6f..42464e1 100644 --- a/examples/html-template/templates/entity.gotpl +++ b/examples/html-template/templates/entity.gotpl @@ -4,21 +4,24 @@

+
{{- range $v := .Fields }} - {{ if eq $v.Key "ID" }} -
: {{ $v.Value }}
+ {{ if $v.IsID }} +
{{ $v.Value }}
{{ else }} {{ if eq $v.Type "time.Time" }} -
:
+
{{ else }} -
: {{ $v.Value }}
+
{{ $v.Value }}
{{ end }} {{ end }} {{- end }} +
+

{{ end }} {{ end }} diff --git a/examples/html-template/templates/entity_form.gotpl b/examples/html-template/templates/entity_form.gotpl index 7c12115..dcace1d 100644 --- a/examples/html-template/templates/entity_form.gotpl +++ b/examples/html-template/templates/entity_form.gotpl @@ -10,21 +10,22 @@ {{ else }}
{{ end }} +
{{- range $f := .Fields }} - {{ if ne $f.Key "ID" }} - {{ if ne ($f.Value | toString) "0" }} -
- : - -
- {{ end }} + {{ if not $f.IsID }} +
+ + +
{{ else }} - {{ if ne ($f.Value | toString) "0" }} -
: {{ $f.Value }}
+
+ + {{ $f.Value }} +
- {{ end }} {{ end }} {{- end }} +
diff --git a/examples/html-template/templates/entity_form_page.gotpl b/examples/html-template/templates/entity_form_page.gotpl index b97273b..07ddb6c 100644 --- a/examples/html-template/templates/entity_form_page.gotpl +++ b/examples/html-template/templates/entity_form_page.gotpl @@ -5,7 +5,9 @@ {{ template "entity_header" }} -

{{ .Name }}

+
+

{{ .Name }}

+
{{ template "entity_form" . }} diff --git a/examples/html-template/templates/entity_list.gotpl b/examples/html-template/templates/entity_list.gotpl index 4cca11e..317a470 100644 --- a/examples/html-template/templates/entity_list.gotpl +++ b/examples/html-template/templates/entity_list.gotpl @@ -1,16 +1,23 @@ {{ define "entity_list" }} {{ $pathPrefix := .PathPrefix }} -

- {{ .EntityName }} - - - - -

+
+

+ {{ .EntityName }} +

+
+
{{ range $k, $v := .Entities }} {{ $wrapped := wrapMetadata $pathPrefix $v }} {{ template "entity" $wrapped }} {{ end }} +
+ +
+
+ + +
+
{{ end }} diff --git a/examples/html-template/templates/entity_page.gotpl b/examples/html-template/templates/entity_page.gotpl index 4f272ef..cc3e1ba 100644 --- a/examples/html-template/templates/entity_page.gotpl +++ b/examples/html-template/templates/entity_page.gotpl @@ -5,8 +5,14 @@ {{ template "entity_header" }} -

{{ .Name }}

- {{ template "entity" . }} +
+

{{ .Name }}

+
+
+
+ {{ template "entity" . }} +
+
{{ end }}