segaja/template

此包已被废弃且不再维护。未建议替代包。

twig/twig的小型封装。

2.0.0 2019-05-17 00:00 UTC

This package is auto-updated.

Last update: 2020-05-31 21:05:15 UTC


README

安装

composer require segaja/template

用法

<?php
$twig = new \Twig\Environment(
    new \Twig\Loader\Filesystem('/path/to/templates/'),
    [ /* twig options array */ ]
);

$template = new \Segaja\Template($twig);

$template->createTemplate('welcomePage');

$template->variable1 = 'Hello world';

$template->display();

以下示例会创建一个读取位于/path/to/templates/目录下模板的twig对象。模板必须以.twig后缀结尾。

最终,加载模板welcomePage,将variable1赋值为"Hello world",并显示模板。