All Projects → beebmx → kirby-blade

beebmx / kirby-blade

Licence: MIT license
Enable Blade for Kirby 3

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to kirby-blade

kirby-blade
Enable Laravel Blade Template Engine for Kirby 3
Stars: ✭ 20 (+42.86%)
Mutual labels:  kirby, blade, templating-engine, kirby-blade
laravel-blade-phpstorm-live-template
PhpStorm Live Templates for Laravel Templates (Blade)
Stars: ✭ 32 (+128.57%)
Mutual labels:  blade, blade-template
edge
[READ ONLY] A Blade compatible template engine with much extendable interface.
Stars: ✭ 26 (+85.71%)
Mutual labels:  blade, blade-template
kirby3-many-to-many-field
This plugin allows you to create many-to-many relationships between pages in Kirby and synchronizes them on both sides.
Stars: ✭ 38 (+171.43%)
Mutual labels:  kirby, kirby-3
kirby-ga
Kirby GA - Google Analytics
Stars: ✭ 16 (+14.29%)
Mutual labels:  kirby, kirby-3
laravel-simple-select
Laravel Simple Select inputs component for Blade and Livewire.
Stars: ✭ 59 (+321.43%)
Mutual labels:  blade, blade-template
kirby-git
Kirby plugin for updating content in the panel via Git
Stars: ✭ 75 (+435.71%)
Mutual labels:  kirby, kirby-3
blade
🏃 A library for using Laravel Blade templates in WordPlate.
Stars: ✭ 28 (+100%)
Mutual labels:  blade, blade-template
field-engineer
A Kirby field for complex field structures.
Stars: ✭ 49 (+250%)
Mutual labels:  kirby
gpp
General PreProcessor
Stars: ✭ 25 (+78.57%)
Mutual labels:  templating-engine
kirby-blade-template
⬢ Laravel Blade template component for Kirby CMS.
Stars: ✭ 26 (+85.71%)
Mutual labels:  blade-template
KirbyComments
[Kirby 2] File-based comments stored as subpages for the Kirby CMS.
Stars: ✭ 68 (+385.71%)
Mutual labels:  kirby
uchroma
An advanced driver for Razer Chroma hardware in Linux
Stars: ✭ 45 (+221.43%)
Mutual labels:  blade
laravel-theme-system
Theme system for Laravel Framework.
Stars: ✭ 71 (+407.14%)
Mutual labels:  blade
selene
A opinionated Wordpress base theme based on Sage.
Stars: ✭ 31 (+121.43%)
Mutual labels:  blade
Kirby-Assistant
用于在安卓平台手机上下载游玩星之卡比系列游戏的应用程序
Stars: ✭ 19 (+35.71%)
Mutual labels:  kirby
kirby-panel-brand
Possible to add a color and a text at the top of the Kirby Panel
Stars: ✭ 18 (+28.57%)
Mutual labels:  kirby-3
better-rest
Kirby plugin for better REST requests
Stars: ✭ 51 (+264.29%)
Mutual labels:  kirby
kirby-map-field
🗺 An easy way to use maps and location data in Kirby.
Stars: ✭ 41 (+192.86%)
Mutual labels:  kirby
blade
A simple, fast, clean, and dynamic language that allows you to develop applications quickly.
Stars: ✭ 113 (+707.14%)
Mutual labels:  blade

Kirby Blade

Kirby Blade use Laravel illuminate/view and jenssegers/blade packages.

This package enable Laravel Blade for your own Kirby applications.

Installation

Installation with composer

composer require beebmx/kirby-blade

What is Blade?

According to Laravel Blade documentation is:

Blade is the simple, yet powerful templating engine provided with Laravel. Unlike other popular PHP templating engines, Blade does not restrict you from using plain PHP code in your views. In fact, all Blade views are compiled into plain PHP code and cached until they are modified, meaning Blade adds essentially zero overhead to your application. Blade view files use the .blade.php file extension.

Usage

You can use the power of Blade like Layouts, Control Structures, Sub-Views, Directives, your Custom If Statements and Blade components.

All the documentation about Laravel Blade is in the official documentation.

Conflicts

Since Kirby 3.7.0 it's important to add the helpers from illuminate/support to your root index.php file in your public directory.

const KIRBY_HELPER_E = false;
// or
define('KIRBY_HELPER_DUMP', false);

This line should be before your autoload.php file. The result file should be like:

<?php

define('KIRBY_HELPER_DUMP', false);

include '../vendor/autoload.php';

// ...

Options

The default values of the package are:

Option Default Values Description
beebmx.kirby-blade.views site/cache/views (string) Location of the views cached
beebmx.kirby-blade.directives [] (array) Array with the custom directives
beebmx.kirby-blade.ifs [] (array) Array with the custom if statements

All the values can be updated in the config.php file.

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:

'beebmx.kirby-blade.views' => '/site/storage/views',

Directives

By default Kirby Blade comes with the follows directives:

@js('js/app.js')
@css('css/app.css')
@kirbytext($page->text())
@kt($page->text())
@kirbytextinline($page->text())
@kti($page->text())
@smartypants($page->text())
@esc($string)
@image($page->image())
@svg($file)
@page($id)
@pages($id)
@markdown($page->text())
@html($page->text())
@h($page->text())
@url($page->url())
@u($page->url())
@go($url)
@asset($page->image())
@translate($translation)
@t($translation)
@tc($translation, $count)
@dump($variable)
@csrf()
@snippet($name, $data)
@twitter($username, $text, $title, $class)
@video($url)
@vimeo($url)
@youtube($url)
@gist($url)

But you can create your own:

'beebmx.kirby-blade.directives' => [
    'greeting' => function ($text) {
        return "<?php echo 'Hello: ' . $text ?>";
    }
],

If Statements

Like directives, you can create your own if statements:

'beebmx.kirby-blade.ifs' => [
    'logged' => function () {
        return !!kirby()->user();
    },
],

After declaration you can use it like:

@logged
    Welcome back {{ $kirby->user()->name() }}
@else
    Please Log In
@endlogged

Components

Now you can use natively blade components in Kirby 3. To display a component its required to place your component in templates/components and then you can call it with the prefix x- in kebab case.

<!-- ../templates/components/alert.blade.php -->

<x-alert/>


<!-- ../templates/components/button.blade.php -->

<x-button></x-button>

If your component is nested deeper inside the components directory, you can use the . character to indicate the place:

<!-- ../templates/components/inputs/button.blade.php -->

<x-inputs.button/>

You can also send data to the components via "slots" and attributes:

<x-alert title="Danger">Message</x-alert>

<!-- ../templates/components/alert.blade.php -->

<div class="alert">
    <div>{{$title}}</div>
    <div>{{ $slot }}</div
</div>

All the documentation related with Components is in the Laravel website.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].