diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-08-10 20:54:46 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-08-10 20:54:46 +0200 |
commit | 446b273352cdba17d899859782964c8e35d751b2 (patch) | |
tree | cc739d43742572269131afb1aa99d6542287ff01 | |
parent | 7bda6af2b8a9c32124139ea12cf7d0f25f40b50b (diff) |
Move countries into its own function
-rw-r--r-- | templates/base.go | 35 | ||||
-rw-r--r-- | templates/coins_designs.templ | 36 |
2 files changed, 36 insertions, 35 deletions
diff --git a/templates/base.go b/templates/base.go index e6647f2..ba31baf 100644 --- a/templates/base.go +++ b/templates/base.go @@ -1,3 +1,36 @@ +//go:generate templ generate -log-level warn + package templates -//go:generate templ generate -log-level warn +import "git.thomasvoss.com/euro-cash.eu/i18n" + +type country struct{ code, name string } + +func countries(p i18n.Printer) []country { + return []country{ + {code: "AD", name: p.T("Andorra")}, + {code: "AT", name: p.T("Austria")}, + {code: "BE", name: p.T("Belgium")}, + {code: "CY", name: p.T("Cyprus")}, + {code: "DE", name: p.T("Germany")}, + {code: "EE", name: p.T("Estonia")}, + {code: "ES", name: p.T("Spain")}, + {code: "FI", name: p.T("Finland")}, + {code: "FR", name: p.T("France")}, + {code: "GR", name: p.T("Greece")}, + {code: "HR", name: p.T("Croatia")}, + {code: "IE", name: p.T("Ireland")}, + {code: "IT", name: p.T("Italy")}, + {code: "LT", name: p.T("Lithuania")}, + {code: "LU", name: p.T("Luxembourg")}, + {code: "LV", name: p.T("Latvia")}, + {code: "MC", name: p.T("Monaco")}, + {code: "MT", name: p.T("Malta")}, + {code: "NL", name: p.T("Netherlands")}, + {code: "PT", name: p.T("Portugal")}, + {code: "SI", name: p.T("Slovenia")}, + {code: "SK", name: p.T("Slovakia")}, + {code: "SM", name: p.T("San Marino")}, + {code: "VA", name: p.T("Vatican City")}, + } +} diff --git a/templates/coins_designs.templ b/templates/coins_designs.templ index 645d0cf..1b1ba6d 100644 --- a/templates/coins_designs.templ +++ b/templates/coins_designs.templ @@ -7,10 +7,6 @@ import ( "git.thomasvoss.com/euro-cash.eu/i18n" ) -type country struct { - code, name string -} - var varietiesLinkStart = `<a href="/coins/varieties">` func makeURL(c country) templ.SafeURL { @@ -19,35 +15,7 @@ func makeURL(c country) templ.SafeURL { } templ CoinsDesigns() { - {{ - p := ctx.Value("printer").(i18n.Printer) - countries := []country{ - {code: "AD", name: p.T("Andorra")}, - {code: "AT", name: p.T("Austria")}, - {code: "BE", name: p.T("Belgium")}, - {code: "CY", name: p.T("Cyprus")}, - {code: "DE", name: p.T("Germany")}, - {code: "EE", name: p.T("Estonia")}, - {code: "ES", name: p.T("Spain")}, - {code: "FI", name: p.T("Finland")}, - {code: "FR", name: p.T("France")}, - {code: "GR", name: p.T("Greece")}, - {code: "HR", name: p.T("Croatia")}, - {code: "IE", name: p.T("Ireland")}, - {code: "IT", name: p.T("Italy")}, - {code: "LT", name: p.T("Lithuania")}, - {code: "LU", name: p.T("Luxembourg")}, - {code: "LV", name: p.T("Latvia")}, - {code: "MC", name: p.T("Monaco")}, - {code: "MT", name: p.T("Malta")}, - {code: "NL", name: p.T("Netherlands")}, - {code: "PT", name: p.T("Portugal")}, - {code: "SI", name: p.T("Slovenia")}, - {code: "SK", name: p.T("Slovakia")}, - {code: "SM", name: p.T("San Marino")}, - {code: "VA", name: p.T("Vatican City")}, - } - }} + {{ p := ctx.Value("printer").(i18n.Printer) }} <header> @navbar() <h1>{ p.T("Euro Coin Designs") }</h1> @@ -58,7 +26,7 @@ templ CoinsDesigns() { </p> <hr/> <div class="country-grid"> - for _, c := range countries { + for _, c := range countries(p) { <a role="button" class="outline" |