Files
umrechner/hugo/layouts/partials/available-currencies.html
2026-05-27 20:04:58 +02:00

20 lines
718 B
HTML

{{ $pbBase := getenv "POCKETBASE_URL" | default site.Params.pocketbase_url }}
{{ $pbUrl := printf "%s/api/collections/currencies/records" $pbBase }}
{{ $pbOpts := dict "method" "GET" "timeout" "15s" "headers" (dict "Accept" (slice "application/json")) }}
{{ $pbCurrencies := slice }}
{{ $pbOk := false }}
{{ with try (resources.GetRemote $pbUrl $pbOpts) }}
{{ with .Err }}
{{ else with .Value }}
{{ with transform.Unmarshal .Content }}
{{ if .items }}
{{ range $record := .items }}
{{ $pbCurrencies = $pbCurrencies | append (lower $record.id) }}
{{ end }}
{{ $pbOk = true }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ return dict "ok" $pbOk "currencies" ($pbCurrencies | append "eur") }}