afbora / kirby-blade

Enable Laravel Blade Template Engine for Kirby 3
MIT License
20 stars 7 forks source link

Is it possible to register/use components? #13

Closed iskrisis closed 3 years ago

iskrisis commented 4 years ago

Is it possible to register/use components? Like here https://laravel.com/docs/7.x/blade#components ?

afbora commented 4 years ago

@iskrisis I have no idea for now, i'll take care 👍

afbora commented 4 years ago

@iskrisis Do you mean old usage like @component('alert') or new usage like <x-alert />?

iskrisis commented 4 years ago

Mostly <x-alert /> but i would think both ways would work if component was registered. I am not sure where to do it or if it is even possible.

afbora commented 4 years ago

I tried to implement the new usage/register(component library) but I got some errors for now. But you can use the old method in current version as @component('alert')

Feel free create PR if you have a solution for new component usage 👍

iskrisis commented 4 years ago

Thanks for the info! I wasn't even aware i can use @component('alert')

afbora commented 4 years ago

Sample Usage

/site/templates/default.blade.php

@component('components.alert')
    <strong>Whoops!</strong> Something went wrong!
@endcomponent

/site/templates/components/alert.blade.php

<div class="alert alert-danger">
    {{ $slot }}
</div>
adamkiss commented 4 years ago

I'll just leave this here - https://github.com/jenssegers/blade/issues/49 - and maybe will look into it later.

iskrisis commented 3 years ago

I've been working with laravel lately and i really like the I have no idea how to bring this to kirby. Are there any news on this? Could i maybe pay one of you for adding this @afbora @adamkiss ? Cheers

afbora commented 3 years ago

@iskrisis Have you look out?

https://github.com/beebmx/kirby-blade

iskrisis commented 3 years ago

@afbora amazing thanks!

adamkiss commented 3 years ago

@iskrisis I've used beebmx/kirby-blade and it works well enough - there was just a couple of issues between the blade and the content representations, if you use those. Otherwise, it works well.

iskrisis commented 3 years ago

👍

RobertCordes commented 2 years ago

PSA: I was having trouble using components the way @afbora described. Using his example, all tags would be escaped/written out. I had to change {{ $slot }} to <?= $slot ?>. Why this is working, I have no idea 🤣 But maybe it helps someone else.