Closed kevinvennitti closed 1 year ago
The docs are probably not as clear on this part. You get all variables that will be available in your snippet. Actually this is nothing I added specifically. If you would replace the snippets
component yourself you would always get at least the kirby
, site
, pages
and page
objects at this point as those are the default variables that are always available in snippets.
Filtering out these variables also makes no sense (at least for the plugin) since you can override any of these default variables as well.
snippet('mysnippet', ['page' => null]);
That's clear, thanks!
(and thanks for the plugin!)
Actually you issue got me thinking. @kevinvennitti what is your actual use case for the $data
array?
Do you use it to actually do a loop over it or do you just need one or more values from the array?
I think it would actually make more sense to pass the $data
as possible args so you could do something like this. This would also help to properly typehint arguments:
<?php
return function (Site $site, mixed $mydata = null, TargetPage $target)
{
return [
//
];
};
Hi!
I am using a snippet controller to fetch snippet data and get
mydata
:$data
should be:Instead,
$data
returns:Am I using it wrong? :)