wherd/signal
最新稳定版本:v1.0.0
Composer 安装命令:
composer require wherd/signal
包简介
Yet another template engine
README 文档
README
Yet another template engine.
Installation
Install using composer:
composer require wherd/signal
Introduction
Signal is yet another simple templating engine. All Signal templates are compiled into plain PHP code and cached, meaning Signal adds essentially zero overhead to your application. Signal template files use the .signal.php file extension.
Create a signal instance by passing it the folder(s) where your view files are located. Render a template by calling the render method.
use Signal\Compiler; use Signal\View; $compiler = new Compiler(__DIR__ . '/views'); $compiler->setCacheDirectory(__DIR__ . '/tmp'); $signal = new View($compiler); echo $signal->render('homepage', ['name' => 'John Doe']);
Displaying Data
You may display data that is passed to your Signal views by wrapping the variable. For example, given the following:
use Signal\Compiler; use Signal\View; $compiler = new Compiler(__DIR__ . '/views'); $compiler->setCacheDirectory(__DIR__ . '/tmp'); $signal = new View($compiler); echo $signal->render('homepage', ['name' => 'John Doe']);
You may display the contents of the name variable like so:
Hello, @{ $name }.
You are not limited to displaying the contents of the variables passed to the view. You may also echo the results of any PHP function. In fact, you can put any PHP code you wish inside of a Signal statement:
The current UNIX timestamp is @{ time() }}.
Displaying Unescaped Data
By default, Signal @{ } statements are automatically sent through PHP's htmlspecialchars function to prevent XSS attacks. If you do not want your data to be escaped, you may use the following syntax:
Hello, @{! $name }.
// TODO
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-02-04