Skip to content

Kirby 4.4.1

Snippets

Add your own snippet loader

/site/plugins/snippet-engine/index.php
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
$name * array|string|null Snippet name
$data array [ ] Data array for the snippet
$slots bool false

Return type

Kirby\Template\Snippet|string