PHPackages                             marcgoertz/shorten-twig - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. marcgoertz/shorten-twig

ActiveLibrary[Templating &amp; Views](/categories/templating)

marcgoertz/shorten-twig
=======================

A Twig extension for the marcgoertz/shorten package.

1.0.0(8mo ago)2138MITPHPPHP &gt;=8.2CI passing

Since Aug 19Pushed 3mo agoCompare

[ Source](https://github.com/mrcgrtz/php-shorten-twig)[ Packagist](https://packagist.org/packages/marcgoertz/shorten-twig)[ Docs](https://github.com/mrcgrtz/php-shorten-twig)[ Fund](https://ko-fi.com/mrcgrtz)[ Fund](https://liberapy.com/mrcgrtz)[ RSS](/packages/marcgoertz-shorten-twig/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (3)Used By (0)

Shorten Twig Extension
======================

[](#shorten-twig-extension)

> A Twig extension for the [`marcgoertz/shorten`](https://github.com/mrcgrtz/php-shorten) package that safely truncates HTML markup while preserving tags, handling entities, and supporting Unicode/emoji with optional word-safe truncation.

[![Test](https://github.com/mrcgrtz/php-shorten-twig/actions/workflows/test.yml/badge.svg)](https://github.com/mrcgrtz/php-shorten-twig/actions/workflows/test.yml)[![Coverage Status](https://camo.githubusercontent.com/d5da142a16c55e5eb84d36b1c8b531e5e8d2539ae2c3201868e6cb9e1f2d476c/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6d72636772747a2f7068702d73686f7274656e2d747769672f62616467652e7376673f6272616e63683d6d61696e)](https://coveralls.io/github/mrcgrtz/php-shorten-twig?branch=main)[![Packagist PHP Version Support](https://camo.githubusercontent.com/c1d57b30270e7d99b5d3d64815229a479f22f7f9018c18b625f715881cf631ab/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d617263676f6572747a2f73686f7274656e2d74776967)](https://camo.githubusercontent.com/c1d57b30270e7d99b5d3d64815229a479f22f7f9018c18b625f715881cf631ab/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d617263676f6572747a2f73686f7274656e2d74776967)[![Packagist Downloads](https://camo.githubusercontent.com/17784d4ceffd7113937eb71b825d794068701fe7e378ebd0fb41258cbab75f90/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d617263676f6572747a2f73686f7274656e2d74776967)](https://camo.githubusercontent.com/17784d4ceffd7113937eb71b825d794068701fe7e378ebd0fb41258cbab75f90/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d617263676f6572747a2f73686f7274656e2d74776967)[![Packagist Stars](https://camo.githubusercontent.com/3b30e95c9836f0d24e6405d4e8c18760778fda16ddf88993f4af14a8c3b7f97a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f73746172732f6d617263676f6572747a2f73686f7274656e2d74776967)](https://camo.githubusercontent.com/3b30e95c9836f0d24e6405d4e8c18760778fda16ddf88993f4af14a8c3b7f97a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f73746172732f6d617263676f6572747a2f73686f7274656e2d74776967)[![MIT License](https://camo.githubusercontent.com/ad64310d49834ae8a948a82a6d5ce148a6ebc5262c3d40305211c9cb327616e0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d72636772747a2f7068702d73686f7274656e2d74776967)](https://github.com/mrcgrtz/php-shorten-twig/blob/main/LICENSE.md)

Installation
------------

[](#installation)

I recommend using [Composer](https://getcomposer.org/) for installing and using the Shorten Twig Extension:

```
composer require marcgoertz/shorten-twig
```

Usage
-----

[](#usage)

### Basic Setup

[](#basic-setup)

```
