lune/template

v0.1.2 2018-04-14 19:10 UTC

This package is auto-updated.

Last update: 2024-09-24 20:29:58 UTC


README

PHP模板

安装

模板在Composer上可用

composer require lune/template

使用方法

$templates = new \Lune\Template\Engine('path/to/templates');
$template = $templates->template('template.php');
$template->render();

传递变量

有多种方法传递变量

$templates = new \Lune\Template\Engine('path/to/templates', ['foo'=>'bar']);
$template = $templates->template('template.php', ['foo'=>'bar']);
$template->render(['foo'=>'bar']);

注册函数

$templates->registerFunction('error', function($message){
   return sprintf('<span class="error">%s</span>', $message);
});