\Dzango\Twig\ExtensionTruncate

A Tiwg extension that truncates text while preservice HTML tags.

Based on http://alanwhipple.com/2011/05/25/php-truncate-string-preserving-html-tags-words/

Summary

Methods
Properties
Constants
getFilters()
getName()
truncate()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

getFilters()

getFilters() 

getName()

getName() 

truncate()

truncate(string  $text, integer  $length = 100, string  $ending = '...', boolean  $exact = false, boolean  $considerHtml = true) : string

Truncates a string up to a number of characters while preserving whole words and HTML tags

Parameters

string $text

String to truncate.

integer $length

Length of returned string, including ellipsis.

string $ending

Ending to be appended to the trimmed string.

boolean $exact

If false, $text will not be cut mid-word

boolean $considerHtml

If true, HTML tags would be handled correctly

Returns

string —

Truncated string.