Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/manuelodelain/linkify-twig-extension
Linkify Twig extension - Converts URLs and email addresses into HTML links
https://github.com/manuelodelain/linkify-twig-extension
Last synced: 21 days ago
JSON representation
Linkify Twig extension - Converts URLs and email addresses into HTML links
- Host: GitHub
- URL: https://github.com/manuelodelain/linkify-twig-extension
- Owner: manuelodelain
- License: mit
- Created: 2016-02-04T07:20:13.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-12-12T09:27:13.000Z (over 4 years ago)
- Last Synced: 2024-05-14T01:42:23.589Z (about 1 month ago)
- Language: PHP
- Homepage:
- Size: 11.7 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Lists
- awesome-twig - Linkify - Twig extension for Linkify - converts URLs and email addresses into HTML links (Twig / Extensions)
- awesome-twig - Linkify - Twig extension for Linkify - converts URLs and email addresses into HTML links (Twig / Extensions)
README
# Linkify Twig extension
Use [Linkify](https://github.com/misd-service-development/php-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 ... www.website.com ...
```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 ... www.website.com ...
```[See the Linkify options](https://github.com/misd-service-development/php-linkify#options)