truncate
Truncate a string to a given number of characters. If you wish to truncate without cutting words in half, use truncate_words instead.
Specification
{{ text | truncate: length=50, truncate_string="..." }}
Parameter | Description | Example Values |
---|---|---|
text (required) | The given text. | “Lorem ipsum dolor sit amet, consectetur adipiscing elit.” |
length | The number of characters to truncate the sentence to. | 50 |
truncate_string | Specifies what to add to the end of the string to indicate that it was truncated. | ‘…’ |
Examples
{{ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vel placerat libero.' | truncate: 10 }}
This will output …
“Lorem ipsu…”