Download the PHP package leitsch/kirby-blade without Composer
On this page you can find all versions of the php package leitsch/kirby-blade. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download leitsch/kirby-blade
More information about leitsch/kirby-blade
Files in leitsch/kirby-blade
Package kirby-blade
Short Description Enable Laravel Blade Template Engine for Kirby 4
License MIT
Informations about the package kirby-blade
Kirby Blade
Kirby Blade use Laravel illuminate/view
11.x package and compatible with Kirby 4.
This package enables Laravel Blade for your own Kirby applications.
Installation
Caveat: Laravel and Kirby both define the e()
helper function, but they do vastly different things. In Kirby, e()
is basically just a shortcut for echo $condition ? $a : $b;
. In Laravel, this function escapes HTML characters in a string. From Kirby 3.7 and up, you have to disable Kirby’s own e()
helper by adding a single line of code to your index.php
, before including the autoload.php
file:
What is Blade?
According to Laravel Blade documentation is:
Blade is the simple, yet powerful templating engine that is included with Laravel. Unlike some PHP templating engines, Blade does not restrict you from using plain PHP code in your templates. In fact, all Blade templates are compiled into plain PHP code and cached until they are modified, meaning Blade adds essentially zero overhead to your application. Blade template files use the .blade.php file extension.
Usage
You can use the power of Blade like Layouts, Forms, Sub-Views, Components, Directives and your custom if statements.
All the documentation about Laravel Blade is in the official documentation.
Options
The default values of the package are:
Option | Default | Values | Description |
---|---|---|---|
leitsch.blade.templates | site/templates | (string) | Location of the templates |
leitsch.blade.views | site/cache/views | (string) | Location of the views cached |
leitsch.blade.directives | [] | (array) | Array with the custom directives |
leitsch.blade.ifs | [] | (array) | Array with the custom if statements |
All the values can be updated in the config.php
file.
Templates
Default templates folder is site/templates
directory or wherever you define your templates
directory, but you can change this easily:
Views
All the views generated are stored in site/cache/views
directory or wherever you define your cache
directory, but you can change this easily:
Directives
By default, Kirby Blade comes with following directives:
But you can create your own:
Kirby Helpers Documentation:
https://getkirby.com/docs/reference/templates/helpers
If Statements
Like directives, you can create your own if statements:
After declaration, you can use it like:
Anonymous components
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:
More about anonymous components in the official Laravel Blade documentation.
Class based components
For class based components, the app namespace must be added to your project composer.json
.
The class must be placed in the site/components
directory and will be autoloaded by the package.
A button class could look like:
The blade file of the button class should be placed in the site/templates/components/button.blade.php
directory.
Hook
For use cases such as HTML minification, there's a custom hook for manipulating rendered HTML output:
Credits
All versions of kirby-blade with dependencies
getkirby/composer-installer Version ^1.2
getkirby/cms Version ^4.0
illuminate/config Version ^11.0
illuminate/view Version ^11.0