beebmx/kirby-blade
Composer 安装命令:
composer require beebmx/kirby-blade
包简介
Blade template for Kirby
README 文档
README
Kirby Blade use Laravel illuminate/view and jenssegers/blade packages.
This package enables 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, 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.bootstrap | false | (bool) | Enable blade facade after the plugin is available |
| 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 Blade components natively 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 to Components is in the Laravel website.
beebmx/kirby-blade 适用场景与选型建议
beebmx/kirby-blade 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.93k 次下载、GitHub Stars 达 14, 最近一次更新时间为 2019 年 01 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「template」 「view」 「blade」 「kirby」 「kirby-plugin」 「kirby4」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 beebmx/kirby-blade 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 beebmx/kirby-blade 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 beebmx/kirby-blade 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
Illuminate View for Morningmedley.
Simple ASCII output of array data
View5 is a version of Blade Templates for the Mvc5 Framework
E2E Studios PHP Framework adaptation of leafsphp/blade package
Yii2 prettyPhoto image galary widget uses Lightbox view control jquery.prettyphoto.js
统计信息
- 总下载量: 1.93k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 14
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-01-23