Download the PHP package marcgoertz/shorten-twig without Composer
On this page you can find all versions of the php package marcgoertz/shorten-twig. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download marcgoertz/shorten-twig
More information about marcgoertz/shorten-twig
Files in marcgoertz/shorten-twig
Download marcgoertz/shorten-twig
More information about marcgoertz/shorten-twig
Files in marcgoertz/shorten-twig
Vendor marcgoertz
Package shorten-twig
Short Description A Twig extension for the marcgoertz/shorten package.
License MIT
Homepage https://github.com/mrcgrtz/php-shorten-twig
Package shorten-twig
Short Description A Twig extension for the marcgoertz/shorten package.
License MIT
Homepage https://github.com/mrcgrtz/php-shorten-twig
Please rate this library. Is it a good library?
Informations about the package shorten-twig
Shorten Twig Extension
A Twig extension for the
marcgoertz/shortenpackage that safely truncates HTML markup while preserving tags, handling entities, and supporting Unicode/emoji with optional word-safe truncation.
Installation
I recommend using Composer for installing and using the Shorten Twig Extension:
Usage
Basic Setup
Template Usage
Output:
Filters
shorten
Safely truncate text or HTML markup using the marcgoertz/shorten library.
Parameters
int $length: Maximum length of truncated text (default:400)string $appendix: Text added after truncated text (default:'…')bool $appendixInside: Add appendix to last content in tags, increases$lengthby 1 (default:false)bool $wordsafe: Wordsafe truncation, cuts at word boundaries (default:false)string $delimiter: Delimiter for wordsafe truncation (default:' ')
Examples
Features
- ✅ Preserves HTML tag structure and proper nesting
- ✅ Handles HTML entities correctly
- ✅ Supports self-closing tags (both XML and HTML5 style)
- ✅ UTF-8 and multibyte character support (including emojis)
- ✅ Wordsafe truncation to avoid cutting words in the middle
- ✅ Configurable suffix text and placement
- ✅ Easy integration with existing Twig templates
- ✅ Full compatibility with
marcgoertz/shortenv5.0+
Requirements
- PHP 8.2+
- Twig 3.0+
marcgoertz/shorten5.0+
Development
Running Tests
Code Style
License
MIT © Marc Görtz
All versions of shorten-twig with dependencies
PHP Build Version
Package Version
The package marcgoertz/shorten-twig contains the following files
Loading the files please wait ...