logifire / nano-template
模板工具
0.2.0
2019-03-12 15:18 UTC
Requires
- php: >=7.2.0
Requires (Dev)
- phpunit/phpunit: ^8.0
This package is auto-updated.
Last update: 2024-08-23 06:39:46 UTC
README
此模板库将视图模型映射到PHP模板文件。默认模板文件命名为 *.tpl.php,但可以更改后缀。例如,Welcome.en.php 和 Welcome.de.php,如果您想有不同的语言模板。
用法
基本用法
$view_namespace = 'NanoTemplate\Test\Model';
$template_path = __DIR__ . '/templates';
$renderer = new Renderer($view_namespace, $template_path);
$view = new Welcome();
$content = $renderer->capture($view);
// $content = $renderer->capture($view, 'en'); If you want to use another suffix
...
将内容添加到PSR-7响应模型,并发出响应。
如果您不使用响应模型,也可以直接打印模板: $renderer->print($view)