tgrj/tweb_view
最新稳定版本:v1.2.0
Composer 安装命令:
composer require tgrj/tweb_view
包简介
minimalistic view engine
README 文档
README
minimalistic view engine
Background
I like the phtml() method of the package noodlehaus/dispatch. I still wanted to extend this method a bit. Thus this extra package.
Usage
While writing this, this package will provide the function tweb_render(template_file, variables), where you can either give an absolute path to a PHTML or PHP file, or a relative one, which is stored in the tweb view folder. No need for the extension, but if none is given, the method first will check if a PHTML files with this name exists, and then a check for PHP. Also you can pass an array with variables, which will be usable in the template.
tweb_view('home/home', ['title' => 'great site']);
It is also possible to use layouts by using a colon ':' in the template_file string like so:
tweb_view('base/layout:home/home', ['title' => 'great site']);
This will (recursive; even when giving something like 'layoutA:layoutB:template' as a string!) use the last given element in the colon-seperated string in the template before that. In the example the template 'home/home' will be used in the template 'base/layout', in which the variable $content should exist!. This variable will be the content of the rendered home/home template.
In the templates or in the variables array you can use the method e() as a wrapper for the htmlspecialchars() php method for security reasons.
统计信息
- 总下载量: 34
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-01