covex-nn / twig-callable-bridge-bundle
此包已被 废弃,不再维护。没有建议的替代包。
提供简单的接口以扩展 Twig 的 PHP 函数
1.1.0
2016-07-08 07:58 UTC
Requires
- php: >=5.3.0
- symfony/twig-bundle: ~2.3|~3.0
Requires (Dev)
- apnet/coding-standard: ~2.0
- knplabs/knp-markdown-bundle: ~1.5
- phpunit/phpunit: ~4.0
- symfony/monolog-bundle: ~2.3|~3.0
- symfony/symfony: ~2.3|~3.0
This package is not auto-updated.
Last update: 2022-02-01 12:34:44 UTC
README
此 Symfony2 扩展包旨在提供简单的接口以扩展 Twig 的 PHP 函数
安装
将依赖项添加到 composer.json
{ "require" : { "covex-nn/twig-callable-bridge-bundle" : "~1.0" } }
注册扩展包
在 AppKernel.php
文件中注册扩展包
// ...other bundles ... $bundles[] = new Covex\TwigCallableBridgeBundle\CovexTwigCallableBridgeBundle();
配置
将配置添加到 config.yml
covex_twig_callable_bridge: functions: uppercase: strtoupper filters: lowercase: strtolower test: numeric: is_numeric
Twig
在 Twig 模板中使用您的函数、过滤器进行测试
{{ uppercase('qqq') }} {{ 'WoW'|lowercase }} {% if 1 is numeric %}yes{% else %}no{% endif %}