You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+50-3Lines changed: 50 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@
9
9
10
10
Kirby Blade use Laravel `illuminate/view` 11.x package and compatible with Kirby 4.
11
11
12
-
This package enables [Laravel Blade](https://laravel.com/docs/9.x/blade) for your own Kirby applications.
12
+
This package enables [Laravel Blade](https://laravel.com/docs/11.x/blade) for your own Kirby applications.
13
13
14
14
## Installation
15
15
@@ -31,9 +31,9 @@ According to Laravel Blade documentation is:
31
31
32
32
## Usage
33
33
34
-
You can use the power of Blade like [Layouts](https://laravel.com/docs/9.x/blade#building-layouts), [Forms](https://laravel.com/docs/9.x/blade#forms), [Sub-Views](https://laravel.com/docs/9.x/blade#including-subviews), [Components](https://laravel.com/docs/9.x/blade#components), [Directives](https://laravel.com/docs/9.x/blade#blade-directives) and your custom if statements.
34
+
You can use the power of Blade like [Layouts](https://laravel.com/docs/11.x/blade#building-layouts), [Forms](https://laravel.com/docs/11.x/blade#forms), [Sub-Views](https://laravel.com/docs/11.x/blade#including-subviews), [Components](https://laravel.com/docs/11.x/blade#components), [Directives](https://laravel.com/docs/11.x/blade#blade-directives) and your custom if statements.
35
35
36
-
All the documentation about Laravel Blade is in the [official documentation](https://laravel.com/docs/9.x/blade).
36
+
All the documentation about Laravel Blade is in the [official documentation](https://laravel.com/docs/11.x/blade).
37
37
38
38
## Options
39
39
@@ -144,6 +144,53 @@ After declaration, you can use it like:
144
144
@endlogged
145
145
```
146
146
147
+
### Anonymous components
148
+
149
+
To define an anonymous component, you only need to place a Blade template within your `site/templates/components` directory. To render an alert component you have to define `site/templates/components/alert.blade.php` and the component can be rendered like:
150
+
151
+
```html
152
+
<x-alert />
153
+
```
154
+
155
+
More about anonymous components in the [official Laravel Blade documentation](https://laravel.com/docs/11.x/blade#anonymous-components).
156
+
157
+
### Class based components
158
+
159
+
For class based components, the app namespace must be added to your project `composer.json`.
160
+
161
+
```json
162
+
{
163
+
"autoload": {
164
+
"psr-4": {
165
+
"App\\": "app/"
166
+
}
167
+
}
168
+
}
169
+
```
170
+
171
+
The class must be placed in the `site/components` directory and will be autoloaded by the package.
172
+
173
+
A button class could look like:
174
+
175
+
```php
176
+
<?php
177
+
178
+
namespace App\View\Components;
179
+
180
+
use Illuminate\Support\Facades\View;
181
+
use Illuminate\View\Component;
182
+
183
+
class Button extends Component
184
+
{
185
+
public function render()
186
+
{
187
+
return View::make('components.button');
188
+
}
189
+
}
190
+
```
191
+
192
+
The blade file of the button class should be placed in the `site/templates/components/button.blade.php` directory.
193
+
147
194
### Hook
148
195
149
196
For use cases such as HTML minification, there's a custom hook for manipulating rendered HTML output:
0 commit comments