alexmasterov/twig-extension
Composer 安装命令:
composer require alexmasterov/twig-extension
包简介
A collection of custom extensions for the Twig template engine
关键字:
README 文档
README
A collection of custom extensions for the Twig template engine.
Extensions
Psr7UriExtension — provides useful functions using PSR-7 HTTP message interface.
| Function | Description |
|---|---|
absolute_url |
Generate an absolute URL for the given absolute or relative path |
relative_path |
Generate a relative path based on the current path of the URI |
Installation
The suggested installation method is via composer:
composer require alexmasterov/twig-extension
Configuration
To activate an extension you need to register it into the Twig environment:
/* * @var $twig Twig_Environment * @var $request ServerRequestInterface */ $twig->addExtension( new AlexMasterov\TwigExtension\Psr7UriExtension(ServerRequestInterface $request) );
The example of registering the extension using Auryn and Diactoros:
$injector = new Auryn\Injector; $injector->alias( Psr\Http\Message\ServerRequestInterface::class, Zend\Diactoros\ServerRequest::class ); /* * @var $twig Twig_Environment */ $twig->addExtension( $injector->make(AlexMasterov\TwigExtension\Psr7UriExtension::class) );
统计信息
- 总下载量: 76
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2016-09-22