Cms: Passing data through a partial to a grandchild partial results in "NULL"

Created on 17 Oct 2020  Â·  7Comments  Â·  Source: statamic/cms

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:
```{{ collection:blog_posts }}
{{ 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" }}

{{ title }}

{{ /partial:components/card }}


`_card.antlers.html` (base card):


{{ slot }}


## 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:




```

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.

bug parser

All 7 comments

Alright, after I bit of playing around, I think I figured out the issue.

In the _card_featured partial, when you are calling the other partial, it's split into two lines, this bit below...

{{ partial:components/card classes="bg-gradient-to-br from-{p_background_color} to-{p_background_color}-900
text-white" }}

If you were to put it into a single line like so, it starts working... as if by magic.

{{ partial:components/card classes="bg-gradient-to-br from-{p_background_color} to-{p_background_color}-900 text-white" }}

Hopefully that solves the problem for you. Thanks for creating the demo repo, super helpful!

I'm keeping this issue open because fixing parameter values being split into multiple lines might be a bug that should be fixed.

Whoa, now that is very interesting. I swear I tried to fix that line break (which was from my prettier/eslint/edtior config I think) and it still didnt work. Thanks for digging in @damcclean, I'll try that on my repo and let you know.

Follow up: I can confirm fixing the line break fixed my particular issue! Thanks so much Duncan! I'm actually happy it was just an error in my code rather than error in the gentlemen's code. 😀

Should I close this? Or if its left open, rename it?

Just keep it open until the gents confirm if it's something that should be fixed or not.

Yeah line breaks like that shouldn't affect it. This is a bug.

This issue has not had recent activity and has been marked as stale — by me, a robot. Simply reply to keep it open and send me away. If you do nothing, I will close it in a week. I have no feelings, so whatever you do is fine by me.

This issue has not had recent activity and has been marked as stale — by me, a robot. Simply reply to keep it open and send me away. If you do nothing, I will close it in a week. I have no feelings, so whatever you do is fine by me.

Hey bot, please keep it open.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

riasvdv picture riasvdv  Â·  4Comments

jimblue picture jimblue  Â·  3Comments

billmn picture billmn  Â·  4Comments

filipac picture filipac  Â·  4Comments

aerni picture aerni  Â·  3Comments