crecket/custom-twig-extension
最新稳定版本:2.2
Composer 安装命令:
composer require crecket/custom-twig-extension
包简介
My custom twig extension
README 文档
README
Content
- Introduction
- Requirements
- Installation
- Usage
- License
Introduction
This repo contains my custom twig extension. In here you'll find a few native php functions added to twig as a twig extension. Things like creating a random number or using json_decode can now be done directly in Twig.
Requirements
- Twig ^1.25
Installation
Composer
- Require the repo with composer
composer require crecket/custom-twig-extension - Add the extension to the twig view (custom_twig_extension is the class)
$twig = new Twig_Environment();
$twig->addExtension(new custom_twig_extension());
Manual
- Download the source
- Require the file
- Add the extension to the twig view
Usage
Using these functions and filters is the same as the native functions and filters.
Quick example:
- print_r()
{{ print_r(array) }}
- json_decode
{{ some_variable|json_decode }}
List
Functions
- dumpPre(var1, var2, var3 ...)
- md5(password)
- password_hash(password)
- phpinfo()
- print_r(array)
- pseudoBytes(length)
- randomHex(length)
- randomInt(length)
- randomString(length)
- unsetSession(key)
- wordwrap(string, length, limiter = "\n", cut)
Filters
- json_decode
- urlDecode
Globals
- sessionVars //Returns all php SESSION variables in array form
统计信息
- 总下载量: 144
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: WTFPL
- 更新时间: 2015-10-30