Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose partial parameters explicitly #11159

Open
JonKaric opened this issue Nov 23, 2024 · 0 comments
Open

Expose partial parameters explicitly #11159

JonKaric opened this issue Nov 23, 2024 · 0 comments
Labels

Comments

@JonKaric
Copy link
Contributor

JonKaric commented Nov 23, 2024

Bug description

Currently, there is no way to expose all parameters passed to a partial without explicitly knowing the parameters you're passing down. It's possible to look at the view but these look to be merged with the current context, polluting the possible parameters with ones that have been passed previously (nested components, for example, but we also came across this issue with the {{ nocache }} tags returning a different context)

We already know the parameters used on just that partial and we're getting them using the special__frontmatter key. However, this is overwritten somewhere down the line but I couldn't find where.

'__frontmatter' => $this->params->all(),

I think it would be good to create another variable, that isn't touched by anything else. Gives us the ability to not worry about scoping, view context etc. We know explicitly what parameters have been passed to that partial.

 '__params' => $this->params->all(), 

How to reproduce

Just a little test between __frontmatter and __params. You'll find the __frontmatter returns empty arrays.

partial.antlers.html

{{ {__frontmatter } | dump }}
{{ {__params } | dump }}

Logs

No response

Environment

Environment
Application Name: Statamic
Laravel Version: 10.48.23
PHP Version: 8.3.10
Composer Version: 2.7.7
Environment: local
Debug Mode: ENABLED
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: file
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Livewire
Livewire: v3.5.12

Statamic
Addons: 5
Sites: 2 (United Kingdom, Français)
Stache Watcher: Enabled
Static Caching: Disabled
Version: 5.38.0 PRO

Statamic Addons
arrowtide/gaia: dev-main
arrowtide/statamic-payment-icons: 1.1.0
jonassiewertsen/statamic-livewire: 3.8.1
marcorieser/tailwind-merge-statamic: 1.1.0
statamic-rad-pack/shopify: 5.0.1

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants