manuelodelain/linkify-twig-extension
最新稳定版本:2.0
Composer 安装命令:
composer require manuelodelain/linkify-twig-extension
包简介
Twig extension for Linkify - converts URLs and email addresses into HTML links
README 文档
README
Use Linkify in your twig template.
Installation
Using Composer: composer require manuelodelain/linkify-twig-extension
Usage
use manuelodelain\Twig\Extension\LinkifyExtension; use Twig\Environment; $twig = new Environment(...); $twig->addExtension(new LinkifyExtension()); {{ 'Lorem ipsum ... www.website.com ...'|linkify }} Will output:
Lorem ipsum ... <a href="www.website.com">www.website.com</a> ... Don't forget to apply the raw filter for an HTML output:
{{ 'Lorem ipsum ... www.website.com ...'|linkify|raw }} Options
As Linkify, set default options at the instanciation or at the method call.
At the instanciation (applied to all links):
use manuelodelain\Twig\Extension\LinkifyExtension; $twig = new Environment(...); $twig->addExtension(new LinkifyExtension(array('attr' => array('target' => '_blank')))); At the method call:
{{ 'Lorem ipsum ... www.website.com ...'|linkify({"attr": {"target": "_blank"}}) }} Will output:
Lorem ipsum ... <a href="www.website.com" target="_blank">www.website.com</a> ... 统计信息
- 总下载量: 70.59k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-04