rdrenth / twig-extension-bundle
Symfony扩展包,提供有用的Twig扩展
1.1.0
2016-07-22 21:13 UTC
Requires
- php: ^5.3.3|^7.0
- danielstjules/stringy: ^2.3
- symfony/framework-bundle: ~2.3|~3.0
- twig/twig: ~1.20|~2.0
Requires (Dev)
- phpunit/phpunit: ^4.8
This package is not auto-updated.
Last update: 2024-09-11 22:53:30 UTC
README
关于
这是一个提供一些Twig扩展的Symfony2扩展包!
Twig扩展
Stringy
此扩展提供了以下过滤器(由Stringy包提供)。
有关每个过滤器的更多信息,请参阅链接。
ascii
{{ 'fòôbàř'|ascii }} {# foobar #}
camelize
{{ 'Camel-Case'|camelize }} {# camelCase #}
dasherize
{{ 'fooBar'|dasherize }} {# foo-bar #}
delimit
{{ 'fooBar'|delimit('::') }} {# foo::bar #}
humanize
{{ 'author_id'|humanize }} {# Author #}
slugify
{{ 'Using strings like fòô bàř'| slugify }} {# using-strings-like-foo-bar #}
titleize
{{ 'i like to watch television'|titleize(['to']) }} {# I Like to Watch Television #}
underscored
{{ 'TestUCase'|underscored }} {# test_u_case #}
lcfirst
{{ 'LowerCaseFirst'|lcfirst }} {# lowerCaseFirst #}
ucfirst
{{ 'upperCaseFirst'|ucfirst }} {# UpperCaseFirst #}
安装
步骤1:使用Composer安装RdrenthTwigExtensionBundle
$ composer require rdrenth/twig-extension-bundle
步骤2:启用扩展包
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Rdrenth\Bundle\TwigExtensionBundle\RdrenthTwigExtensionBundle(), // ... ); }
步骤3:配置您的config.yml
文件
默认情况下,过滤器是禁用的,要启用您想使用的过滤器,可以这样操作
# app/config/config.yml rdrenth_twig_extension: stringy: filters: ascii: ~ camelize: ~
您还可以修改在Twig中使用的过滤器名称
# app/config/config.yml rdrenth_twig_extension: stringy: filters: camelize: filter: camels
或提供默认Stringy包中不可用的额外过滤器(该方法必须存在于Stringy类中)
# app/config/config.yml rdrenth_twig_extension: stringy: extra_filters: - { filter: swap_case, method: swapCase }
许可证
此扩展包采用MIT许可证。请参阅扩展包中的完整许可证。
Resources/meta/LICENSE