north / template
简单的模板系统
v1.0.0
2019-05-30 10:48 UTC
Requires
- php: ^7.1
Requires (Dev)
- phpunit/phpunit: ^6.3
- squizlabs/php_codesniffer: ^3.4
This package is auto-updated.
Last update: 2024-09-07 05:59:45 UTC
README
简单的模板系统。
安装
composer require north/template
示例
更多文档在这里
use North\Template\Template; $template = new Template('path/to/templates'); $template->render('index');
index.php
<?php $this->extend('layouts/app', ['title' => 'Startpage']) ?> <?php $this->block('content') ?> <?php $this->include('partials/content', ['title' => 'Hello, world']) ?> <?php $this->endblock() ?>
layouts/app.php
<!doctype html> <html> <head> <title><?php echo $this->escape($title) ?></title> </head> <body> <?php $this->yield('content') ?> </body> </html>
partials/content.php
<div class="content"> <h1><?php echo $this->escape($title) ?></h1> </div>
许可证
MIT © Fredrik Forsmo