Implement simple shortcode to fetch data from 'data/values.yaml'

pull/10/head
sixtus 2021-09-26 21:10:28 +02:00
parent e4bd4855b5
commit c2822d06d5
3 changed files with 22 additions and 4 deletions

View File

@ -17,19 +17,19 @@ aliases:
### Empfänger
> `dezentrale e.V.`
> `{{< value "account" "recepient" >}}`
### Institut
> `Sparkasse Leipzig`
> `{{< value "account" "institution" >}}`
### IBAN
> `DE48 8605 5592 1090 1699 29`
> `{{< value "account" "iban" >}}`
### BIC
> `WELADE8L`
> `{{< value "account" "bic" >}}`
Für Spenden oder Mitgliedsbeiträge stellen wir gerne eine steuerabzugsfähige

5
data/values.yaml Normal file
View File

@ -0,0 +1,5 @@
account:
recepient: dezentrale e.V.
institution: Sparkasse Leipzig
iban: DE48 8605 5592 1090 1699 29
bic: WELADE8L

View File

@ -0,0 +1,13 @@
{{- $section := default (.Get 0) (.Get "section") -}}
{{- $key := default (.Get 1) (.Get "key") -}}
{{- $value := index $.Site.Data.values $section $key -}}
{{- if not $section }}
{{- errorf "missing parameter 'section': %s" .Position }}
{{- end }}
{{- if not $key }}
{{- errorf "missing parameter 'key': %s" .Position }}
{{- end }}
{{- if not $value }}
{{- errorf "missing, empty or null value at 'values/%s.%s': %s" $section $key .Position }}
{{- end }}
{{- $value -}}