Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/TechWilk/twig-linewrap
TWIG filter to wrap lines exceeding the specified length.
https://github.com/TechWilk/twig-linewrap
Last synced: 21 days ago
JSON representation
TWIG filter to wrap lines exceeding the specified length.
- Host: GitHub
- URL: https://github.com/TechWilk/twig-linewrap
- Owner: TechWilk
- License: mit
- Created: 2017-07-06T16:04:11.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2017-07-06T18:56:17.000Z (almost 7 years ago)
- Last Synced: 2024-05-15T11:43:31.209Z (about 1 month ago)
- Language: PHP
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Lists
- awesome-twig - Linewrap - Twig filter to wrap lines exceeding the specified length. (Twig / Extensions)
- awesome-twig - Linewrap - Twig filter to wrap lines exceeding the specified length. (Twig / Extensions)
README
# Line Wrap (filter for TWIG)
[![Total Downloads](https://img.shields.io/packagist/dt/techwilk/twig-linewrap.svg)](https://packagist.org/packages/techwilk/twig-linewrap)
[![Latest Stable Version](https://img.shields.io/packagist/v/techwilk/twig-linewrap.svg)](https://packagist.org/packages/techwilk/twig-linewrap)
[![License](https://img.shields.io/packagist/l/techwilk/twig-linewrap.svg)](https://packagist.org/packages/techwilk/twig-linewrap)TWIG filter to wrap lines over a specified length with a newline, or optionally pass in a different separator.
Designed for wrapping iCal files to 75 chars max length, although should be useful in any application requiring line wrapping.
## Installation
1. Install through composer.
```
composer require techwilk/twig-linewrap
```2. Then add as an extension to TWIG:
``` php
$twig->addExtension(new \TechWilk\Twig\Extension\LineWrap());
```## Use
Use as a standard twig filter, passing in a maximum length after which to wrap:
``` twig
{{ 'this is some text that goes on forever' | linewrap(10) }}
```outputs:
```
this is so
me text th
at goes on
forever
```Optionally pass in a different separator (such as for [iCal wrapping](examples/ical-wrapping.md)):
``` twig
{{ 'this is some text that goes on forever' | linewrap(75, "\n ") }}
```