3.6. Function reference
3.6.34. truncate()
3.6.33. sum()
« Previous
3.6.35. upper()
Next »

3.6.34. truncate()

Referencestring truncate(string $text, integer $length [, string $ending [, boolean $breakWords ]])

Truncates the text $text to the specified $length. Optionally, you might define the $ending that is added to the $text, if it has been truncated. The last argument allows to control if the function might break words (true, default value) or not (false). Below you can see a sample results for the text This is a very long text that needs to be truncated:

{@text is 'This is a very long text that needs to be truncated'}
 
<!-- result: "This is a very lo" -->
{truncate(@text, 17)}
 
<!-- result: "This is a very lo..." -->
{truncate(@text, 17, '...')}
 
<!-- result: "This is a very long text that needs to be truncated" -->
{truncate(@text, 500, '...')}
 
<!-- result: "This is a very..." -->
{truncate(@text, 17, '...', false)}

This function can operate also on a container of strings, truncating them all and returning the modified container.

3.6.34. truncate()
3.6. Function reference
« Previous
3.6.33. sum()
Next »
3.6.35. upper()