-
-
Notifications
You must be signed in to change notification settings - Fork 186
Open
Description
Description
To my understanding, templates and snippets are always provided with a $data variable. I could not find any documentation regarding that.
I just wanted to use an optional $data variable myself as a snippet attribute and found out that if I do not pass anything for it, I get the value of the ominous $data variable.
@fabianmichael told me the variable is being defined here: https://github.com/getkirby/kirby/blob/main/src/Filesystem/F.php#L423
Expected behavior
Fabian also suggested to
- either note this behaviour somewhere in the documentation
- or instead use a UUID, possibly somewhat like this:
function tpl($data) {
$varName = '__' . bin2hex(random_bytes(16));
$$varName = $data;
unset($data);
extract($$varName);
// include template file
}To reproduce
- Use fresh Kirby Plainkit
- Dump
$datain template/snippet
Your setup
Kirby Version
5.0.4
Metadata
Metadata
Assignees
Labels
No labels