Skip to content

Passing data through a partial to a grandchild partial results in "NULL" #2671

@austriker27

Description

@austriker27

Bug Description

I'm attempting to pass data from the CMS via a {{ collection }} loop through a child partial to the origin's grandchild partial. This is because I have a base card partial that I've extended with modified card partials like _card_featured

I think this is a bug based on my testing. I've tried a bunch of different solutions including different syntax, raw modifier and scoping the passed data.

Example:

Parent HTML:

    {{ partial:blog_posts/card_featured
        :p_background_color="background_color"
        :p_title="card:title"
    }}
    {{ /collection:blog_posts }}

blog_posts/card_featured partial:

{{ partial:components/card classes="bg-gradient-to-br from-{p_background_color} to-{p_background_color}-900
text-white" }}
<div class="p-4">
    <h3>{{ title }}</h3>
</div>
{{ /partial:components/card }}

_card.antlers.html (base card):

<a href="#" class="flex flex-col rounded-sm shadow group {{ classes }}">
    {{ slot }}
</a>

How to Reproduce

I have replicated the issue in a new clean Statamic V3 repo and stripped out all unnecessary things.

  1. Clone this repo: https://github.com/austriker27/statamic-partial-grandchild
  2. Inspect the centered <a> tag on the page and you will see the gradient classes have NULL in them. However when you {{ dump }} you will see the data is correct there.
    Rendered HTML:
<a href="#" class="flex flex-col rounded-sm shadow group bg-gradient-to-br from-NULL to-NULL-900
text-white">
    <div class="p-4">
    <h3>Yada, yada, yada...</h3>
</div>
</a>

Extra Detail

YAML file with the background_color data

Environment

Statamic 3.0.19 Solo
Laravel 8.10.0
PHP 7.4.8
No addons installed

Install method (choose one):

  • Fresh install from statamic/statamic

Thanks gents! Statamic is the best thing ever and I appreciate you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions