fenom/docs/mods/truncate.md

22 lines
865 B
Markdown
Raw Normal View History

2014-01-29 12:01:31 +04:00
Modifier truncate
=================
2013-02-09 10:59:08 +04:00
2014-01-29 12:01:31 +04:00
Modifier truncates a variable to a character length.
2013-02-09 10:59:08 +04:00
```smarty
{$long_string|truncate:$length:$etc:$by_words:$middle}
2013-02-09 10:59:08 +04:00
```
2014-01-29 12:01:31 +04:00
* `$length`, required. Parameter determines how many characters to truncate to.
* `$etc`, by default `...`. This is a text string that replaces the truncated text.
* `$by_word`, by default **FALSE**. This determines whether or not to truncate at a word boundary with TRUE, or at the exact character with FALSE.
* `$middle`, by default **FALSE**. This determines whether the truncation happens at the end of the string with FALSE, or in the middle of the string with TRUE.
2013-02-09 10:59:08 +04:00
```smarty
{var $str = "very very long string"}
{$str|truncate:10:" read more..."} output: very very read more...
{$str|truncate:5:" ... ":true:true} output: very ... string
```
2014-01-29 12:01:31 +04:00
Modifier do not use `mbstring` when works with UTF8.