Skip to content

TWIG filter to wrap lines exceeding the specified length.

License

Notifications You must be signed in to change notification settings

TechWilk/twig-linewrap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Line Wrap (filter for TWIG)

Total Downloads Latest Stable Version License

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
  1. Then add as an extension to TWIG:
$twig->addExtension(new \TechWilk\Twig\Extension\LineWrap());

Use

Use as a standard twig filter, passing in a maximum length after which to wrap:

{{ '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):

{{ 'this is some text that goes on forever' | linewrap(75, "\n ") }}

About

TWIG filter to wrap lines exceeding the specified length.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages