zenstruck / slugify-bundle
v1.1.1
2013-12-11 15:33 UTC
Requires
- cocur/slugify: ~0.2
- symfony/symfony: ~2.1
This package is not auto-updated.
Last update: 2022-02-01 12:24:34 UTC
README
已弃用,推荐使用cocur/slugify,该软件包现在包括Symfony2 Bundle
此软件包提供了将Slugify库集成到Symfony2中的功能。提供slugify服务和twig过滤器。
安装
-
使用composer安装
php composer.phar require zenstruck/slugify-bundle
-
启用软件包
// app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Zenstruck\SlugifyBundle\ZenstruckSlugifyBundle() ); }
使用服务
/** @var Cocur\Slugify\Slugify $slugify */ $slugify = $this->container->get('zenstruck.slugify');
使用Twig过滤器
{{ 'Hello World!'|slugify }} {# hello-world #} {# custom space separator #} {{ 'Hello World!'|slugify('_') }} {# hello_world #} {# custom space separator and custom replacement for emptyValue #} {{ '####'|slugify('_', 'non') }} {# non #}
完整的默认配置
zenstruck_slugify: twig: true #enable twig filter mode: array #iconv or array mode