Defining variables in a partial and using them in a page -> possible?

hi :slight_smile:

i do not want to copy this code all over my pages - so i thought of exporting it into a partial file - so i would only have to alter that file in order to do changes. but it does not work. is it a scope issue? is this possible at all - defining variables in a partial, binding it in my page and using those variables? - i think it should be - what do you think?

{{$c1ns := .Site.Params.categorynamessmall.category1}}
{{$c2ns := .Site.Params.categorynamessmall.category2}}
{{$c3ns := .Site.Params.categorynamessmall.category3}}
{{$c4ns := .Site.Params.categorynamessmall.category4}}

No.

See

oh well - so there definitely has to happen something with the variables’ scopes.

i have so much redundant code :frowning:

thank you.

I think it would lead to even more issues and confusion if the variables were globally scoped, so the smart people in Google has done mostly right here.

But there should be a workaround, I agree. So I added that writable context in that pull request. If @spf13 agrees it’s a good idea, we can merge that in.