statamic / v2-hub

Statamic 2 - Feature Requests and Bug Reports
https://statamic.com
95 stars 5 forks source link

Globals not accessible in partial #2413

Closed themazim closed 5 years ago

themazim commented 5 years ago

Describe the bug Globals are not accessible in partials, value is always null / empty.

To Reproduce create replicator with multiple blocks and loop through the blocks, passing the content to partial, just like in the tutorial from

https://learnstatamic.com/courses/126671/lectures/2279659

{{if blocks}}
    {{blocks as="block"}}
        {{block | partial:type}}
    {{/blocks}}
{{/if}}

Expected behavior Global variable i.e. {{ site_name }} should print "Website Name" within partial

themazim commented 5 years ago

Turns out piping data into a partial fully cleans all other scopes: https://docs.statamic.com/modifiers/partial (first sentence)

By using:

{{if blocks}}
    {{blocks}}
        {{partial:type}}
    {{/blocks}}
{{/if}}

Everything is working fine.