Getting the array with .Site.Params.*

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.

The config file is not a template. Hence you can’t use Go template syntax in it.

I want to use it in a layout. Not in the config file. Sorry for my English

No problem. If I understood you correctly, you want to render partials like calender whose background color is defined in the config file? Furthermore, there order should be defined by the weight attribute, right?

What confused me was the part below where I thought you mixed template code with the config

weight = 5 {{ partial "calendar" (dict "bgColor" "white") }}

Next, I wasn’t sure over what you’re ranging:

{{ range $index, $paramsName }}
{{ end }}

No, color is defined in if condition. If an odd integer then backround is white, If an even integer then backround is gray. Like Striped Table

Yes, right. And only those that have enable = 1.

Thank you for the further clarification. To sort your “widgets” (authors, news etc.) you could use the sort template function. One optional parameter is the attribute (here weight) which should be used as sort criterion.

I suggest, that you put your “widgets” in a new namespace because it’s likely that you’ll add other things to the params block in the config file that shouldn’t be sorted and displayed. Perhaps something like [params.widgets.news].

Now, you only have to filter out all disabled widgets.