kenshodigital/kirby-snippet
最新稳定版本:1.0.0
Composer 安装命令:
composer require kenshodigital/kirby-snippet
包简介
Adds controllers to Kirby snippets.
README 文档
README
Adds controllers to Kirby snippets.
General
Brings Kirby’s mechanism for template controllers to snippets and blocks. This provides a unified and consistent way to offload logic and prepare data for cleaner templates and snippets.
How it works
The plugin uses Kirby’s native features and extension points. It looks for a controller whenever a snippet is called, and passes the resulting controller data to the snippet.
Since blocks are also just rendered as snippets under the hood, this works for blocks as well.
Installation
composer require kenshodigital/kirby-snippet ^1.0
Usage
Snippet controllers are loaded from a snippets folder under the configured root for controllers.
Just as template controllers and templates, snippet controllers are identified by the same filename as their corresponding snippets.
| Snippet | Snippet Controller |
|---|---|
/site/snippets/article.php |
/site/controllers/snippets/article.php |
/site/snippets/blocks/video.php |
/site/controllers/snippets/blocks/video.php |
As usual, snippet controllers are anonymous functions that receive the snippet data as arguments and return variables as an associative array. The resulting controller data is then merged with the original snippet data, before everything is passed to the snippet.
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-03-18