alexkuusk/malli
最新稳定版本:v0.1
Composer 安装命令:
composer require alexkuusk/malli
包简介
Slim PHP template parser
README 文档
README
A simple and lightweight PHP templating engine using few custom tags that all are translated into pure PHP. PHP is also allowed inside templates, just be aware of the scopes. Template blocks are compiled into PHP functions and functions are called and their output captured.
Possibility to add custom tags, for example translation code. That code's output can be turned into static and saved along with PHP code, so that heavy translating functions are not called every page load. Supports multilanguage and multisite, just pass language parameter and use dynamic path with another set of templates ('path' => '../tpl/' . $_SERVER['SERVER_NAME'] . '/').
Blocks can be nested inside blocks.
Requires PHP version 8.2+
Setup
See Example folder for more complex examples
composer install alexkuusk/malli
minimal
require_once '../vendor/autoload.php'; use Alexkuusk\Malli\Malli; echo (new Malli([ '_params' => [ 'path' => '../tpl/', 'file' => 'index.tpl', 'block' => 'index', //if omitted, file name without extension is used ], '_data' => [ 'title' => 'Template test', 'books' => [ 'One', 'two', ] ]));
index.tpl
{{ BLOCK:index }} <html> <head> <title>{{ $title }}</title> </head> <body> <table border=1> {{ FOREACH $books as $k => $title }} <tr> <td>{{ $k + 1 }}</td> <td>{{ htmlspecialchars($title) }}</td> </tr> {{ /FOREACH }} </table> </body> </html> {{ /BLOCK:index }}
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2024-02-10