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 |
|---|---|---|---|
| $kirbyrequired | Kirby\Cms\App |
no default value | |
| $namerequired | stringorarray |
no default value | Snippet name |
| $data | array |
[ ]
|
Data array for the snippet |
| $slots | bool |
false
|
Return types
Kirby\Template\Snippetorstring