misd/linkify-bundle
最新稳定版本:v1.0.5
Composer 安装命令:
composer require misd/linkify-bundle
包简介
Converts URLs and email addresses in text into HTML links
README 文档
README
Adds Linkify to your Symfony application, which converts URLs and email addresses in HTML (or plain text) to HTML links.
Installation
-
Add the LinkifyBundle to your dependencies:
$ composer require misd/linkify-bundle -
Register the bundle in your application:
// app/AppKernel.php class AppKernel extends Kernel { // ... public function registerBundles() { $bundles = array( // ... new Misd\LinkifyBundle\MisdLinkifyBundle(), // ... ); } // ... }
Usage
Use the service:
$text = $this->container->get('misd.linkify')->process('This is my text containing a link to www.example.com.');
In a Twig template:
{{ "This is my text containing a link to www.example.com."|linkify }}
In a PHP template:
<?php echo $view['linkify']->process('This is my text containing a link to www.example.com.') ?>
Options
Requires Linkify v1.1.1 or newer.
An array of options can be passed (see the Linkify docs for futher details). So to add the link class to created links:
Using the service:
$text = $this->container->get('misd.linkify')->process('This is my text containing a link to www.example.com.', array('attr' => array('class' => 'link')));
In a Twig template:
{{ "This is my text containing a link to www.example.com."|linkify({'attr': {'class': 'link'}}) }}
In a PHP template:
<?php echo $view['linkify']->process('This is my text containing a link to www.example.com.', array('attr' => array('class' => 'link'))) ?>
统计信息
- 总下载量: 87.74k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2012-09-19