Snippets
Add your own snippet loader
use Kirby\Template\Snippet;
Kirby::plugin('my/snippet', [
'components' => [
'snippet' => function (Kirby $kirby, string $name, array $data = [], bool $slots = false): Snippet|string {
return YourSnippetLoader::factory($name, $data, $slots);
}
]
]);
Parameters
Name | Type | Default | Description |
---|---|---|---|
$kirby * | Kirby\Cms\App |
– | Kirby instance |
$name * | array |string |null |
– | Snippet name |
$data | array |
[ ] |
Data array for the snippet |
$slots | bool |
false |
Return type
Kirby\Template\Snippet
|string