truncatewords

Shorten text to a word limit.

View Markdown

Syntax

{{ value | truncatewords:20 }}{{ value | truncatewords:(20, "...") }}

Usage

  • The required first parameter is a non-negative word limit.
  • The suffix defaults to . Pass a second parameter to replace it, or "" to omit it.
  • The suffix is appended after the requested number of words.
  • Whitespace within the retained text is preserved.
  • For arrays and objects, including serialized collections from another filter, string values are formatted recursively while keys and non-string values are preserved.

Examples