Line Wrap (filter for TWIG)
, (*1)
TWIG filter to wrap lines over a specified length with a newline, or optionally pass in a different separator., (*2)
Designed for wrapping iCal files to 75 chars max length, although should be useful in any application requiring line wrapping., (*3)
Installation
- Install through composer.
composer require techwilk/twig-linewrap
- Then add as an extension to TWIG:
``` php
$twig->addExtension(new \TechWilk\Twig\Extension\LineWrap());, (*4)
## 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:, (*5)
this is so
me text th
at goes on
forever
Optionally pass in a different separator (such as for iCal wrapping):, (*6)
twig
{{ 'this is some text that goes on forever' | linewrap(75, "\n ") }}
, (*7)