I have
config.toml
baseurl = '/'
theme = 'mytheme'
languageCode = 'ru'
[params]
version= '4'
month = 'February, 2017'
imgThemeDir = 'images/'
[params.news]
enable = 1
weight = 10
[params.interesting]
enable = 0
weight = 20
banner = 1
bannerFile = 'img.gif'
[params.faces]
enable = 1
weight = 30
[params.authors]
enable = 0
weight = 40
[params.calendar]
enable = 1
weight = 5
I need to get an array of params.* with param name where enable = 1. It’s sorted by weight.
It array is needs to insert partials in loop in a layout and set backround color:
{{ range $index, $paramsName }}
{{ if modBool (add $index 1) 2 }}
{{ $bgColor := "gray" }}
{{ else }}
{{ $bgColor := "white" }}
{{ end }}
{{ partial . (dict "bgColor" $bgColor) }}
{{ end }}
With my example of config.toml in a layout after loop it will be:
{{ partial "calendar" (dict "bgColor" "white") }}
// in the 1st place because calendar has weight = 5
{{ partial "news" (dict "bgColor" "gray") }}
// 2nd - news has weight = 10
{{ partial "faces" (dict "bgColor" "white") }}
// 3rd - faces has weight = 30
interesting and authors will be ignored because enable = 0.