phptransformers/phptransformer
最新稳定版本:1.0.0
Composer 安装命令:
composer require phptransformers/phptransformer
包简介
Normalize the API of any PHPTransformer.
关键字:
README 文档
README
Common interface to manipulate strings/data with any transformer. Great for use in templating libraries, static site generators, web frameworks, and more. Inspired by JSTransformers.
Supported Transformers
To use each of these transformers, you will also need to composer require them in your project.
- Twig (From SensioLabs/Symfony)
- Smarty
- Mustache
- Latte (From Nette Framework)
- StringTemplate
- Plates (From The PHP League)
- Dwoo
- Blade (From Laravel Framework)
- PHPTAL
- Text-Template (From PHPUnit)
Install
Via Composer
$ composer require phptransformers/phptransformer
Usage
// With "phptransfomers/twig" package $transformer = new PhpTransformers\Twig\TwigTransformer(); echo $transformer->render('Hello, {{ name }}!', array( 'name' => 'World' )); //=> Hello, World!
API
Before all examples, you will need to load a transformer:
$transformer = new PhpTransformers\Twig\TwigTransformer(); $transformer = new PhpTransformers\Smarty\SmartyTransformer(); // ... same thing for all other Transformers
See each transformers' repository for more details
->render($template, $locals)
Renders the given template string, using the provides locals for options passed in. Returns the result as a string.
$locals = array('name' => 'World'); $output = $transformer->render('Hello, {{ name }}!', $locals);
->renderFile($file, $locals)
Renders the given file, using the provided locals for options passed in. Returns the result as a string.
$locals = array('name' => 'World'); $output = $transformer->renderFile('hello.twig', $locals);
Testing
$ composer test
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 220
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 1
- 依赖项目数: 11
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-04-23
