coduo / tutu-twig-extension
为 TuTu twig 模板引擎添加新功能。
1.0.0
2016-11-20 17:21 UTC
Requires
- php: >=5.5.0
- twig/twig: 1.*
Requires (Dev)
- behat/behat: 3.0.*
- behat/mink-extension: ~2.0
- behat/mink-goutte-driver: ~1.0
- bossa/phpspec2-expect: ~1.0
- coduo/tutu: 1.0.*
- coduo/tutu-faker-extension: 1.0.*
This package is auto-updated.
Last update: 2024-09-20 07:42:38 UTC
README
此扩展为 Twig 添加新功能
要使用扩展,只需将其添加到 TuTu 的 composer 依赖项中
$ composer require coduo/tutu-twig-extension
在 TuTu 配置中启用扩展
# config/config.yml
extensions:
Coduo\TuTu\Extension\Twig: ~
从现在起,您应该可以在 twig 中使用以下功能
过滤器
json_decode
- 将 JSON 解码为数组/对象
参数
- $asArray - true
- $depth - 512
示例
{% set user = request.content|json_decode %}
{
"id": 1,
"email": {{ user.name }}
}