Accessing global variables from within a 'with'

Hi all,

I’m using a with clause in a page:

{{ with .Site.Data.team }}
{{ .title }} - {{ .text }}
{{ end }}

Is there a way to access the .Section variable from within the with clause? If used literally, with is trying to find it in the remapped context.

Best regards,
Jakub

Prepend the dollar sign $.Section

The with function comes with its own context, so that if its condition is not met the code block is skipped.

Always use the dollar sign when you want to access the higher context.

To access the global context from anywhere, simply use the site function as it is more terse than $.Site

1 Like

Works great, thank you

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.