Skip to content

Releases: lukaskleinschmidt/kirby-snippet-controller

2.2.0

06 Nov 15:25
Compare
Choose a tag to compare

Added option to prevent a snippet from rendering

Using the snippet_prevent() function in your controller callback can now prevent a snippet from being rendered.

snippet('header', data: ['size' => $page->size()])

// header.controller.php

return function (Field|string $size = null) {
    if (is_null($size)) {
        snippet_prevent();
    }

    return [
        'size' => $size,
    ];
};

2.1.0

18 Sep 12:15
57bcda1
Compare
Choose a tag to compare

Updating variables when using a controller callback

Controller callbacks will now override variables.

snippet('header', data: ['size' => $page->size()])

// header.controller.php

return function (Field|string $size = null) {

    if ($size instanceof Field) {
        $size = $size->value();
    }

    $size = match ($size) {
        'small'  => 'height: 50vh',
        'medium' => 'height: 80vh',
        default  => 'height: 100vh',
    };

    return [
        'size' => $size,
    ];
};

Full Changelog: 2.0.1...2.1.0

2.0.1

04 Aug 14:24
83f63b4
Compare
Choose a tag to compare

Full Changelog: 2.0.0...2.0.1

2.0.0

04 Aug 14:19
Compare
Choose a tag to compare

Updated controller callback arguments

If you previously used the $data attribute in your controller callback you can migrate by using a variadic argumend ...$data instead.

1.0.0

05 Jan 09:12
Compare
Choose a tag to compare

Release