lukasleitsch / kirby-blade

Enable Laravel Blade Template Engine for Kirby 4
MIT License
17 stars 4 forks source link

Slots still appear to be broken #36

Closed Pechente closed 6 months ago

Pechente commented 6 months ago

Looks like #34 didn't add slots correctly or maybe I'm missing something here. Here's a minimal example that doesn't work:

templates/default.blade.php

@snippet('layout/default', slots: true)
---content---

snippets/layout/default.blade.php

---header---
{!! $slot ?? '' !!}
---footer---

expected output would be to have the content between the header and footer. instead it's output after it. Seems like slots are being completely ignored.

Am I doing something wrong here?

I created a minimum non-working demo here: https://github.com/Pechente/kirby-blade-slots-demo.git

lukasleitsch commented 6 months ago

The combination of blade snippets with slots is not working/supported. You have to use a plain PHP snippet to use the Kirby slots.

Try to rename snippets/layout/default.blade.php into snippets/layout/default.php.

Background: If the snippet is a Blade file it's rendered by Blade and the rending by Kirby, that handles the slots, is skipped.

To organize your templates in Blade, you can use Component. Blade components also support slot. Or include subviews.