From e242ad3e00d7e1e00a3881a67d381f90d48e859c Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Sun, 10 May 2026 11:52:36 -0400 Subject: [PATCH] feat(templates): add helper functions for metadata editor form rendering Add textToString, tagSliceToString, stringSliceToString, and formatDateForInput to convert pgtype/[]string values into HTML input value attributes for the metadata editor form fields. --- templates/utils.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/templates/utils.go b/templates/utils.go index 9ad94f1..c0d3ddf 100644 --- a/templates/utils.go +++ b/templates/utils.go @@ -220,3 +220,25 @@ func FormatTimestamptzInTimezone(t pgtype.Timestamptz, timezone string) string { } return FormatInTimezone(t.Time, timezone) } + +func textToString(t pgtype.Text) string { + if t.Valid { + return t.String + } + return "" +} + +func tagSliceToString(tags []string) string { + return strings.Join(tags, ", ") +} + +func stringSliceToString(s []string) string { + return strings.Join(s, ", ") +} + +func formatDateForInput(d pgtype.Date) string { + if !d.Valid { + return "" + } + return d.Time.Format("2006-01-02") +}