truncate
string | truncate: number
returns string
Truncates a string down to a given number of characters.
If the specified number of characters is less than the length of the string, then an ellipsis (...) is appended to
the truncated string. The ellipsis is included in the character count of the truncated string.
{{ article.title | truncate: 15 }}
Code
{{ article.title | truncate: 15 }}Data
{
"article": {
"title": "How to tell if you're out of invisibility potion"
}
}Output
How to tell ...
Output
How to tell ...Anchor to Specify a custom ellipsis
Specify a custom ellipsis
string | truncate: number, string
You can provide a second parameter to specify a custom ellipsis. If you don't want an ellipsis, then you can supply an empty string.
{{ article.title | truncate: 15, '--' }}
{{ article.title | truncate: 15, '' }}
Code
{{ article.title | truncate: 15, '--' }}
{{ article.title | truncate: 15, '' }}Data
{
"article": {
"title": "How to tell if you're out of invisibility potion"
}
}Output
How to tell i--
How to tell if
Output
How to tell i--
How to tell ifWas this page helpful?