truncate Filter

Cuts a string down to a given number of characters.

Parameters

Parameter Required Description
length Yes string Number of characters to limit string to. The length of the append parameter is included in this count.
append No string String to append to the end of the truncated string. This defaults to a 3-character ellipsis (...).

Category

String Filters

Description

The truncate filter cuts a string off at a given length. A second parameter indicates a string to append to the end of the chopped string.

      {{ "Long, long, long, long sentence." | truncate: 10 }}
      {{ "Long, long, long, long sentence." | truncate: 10, '.' }}
      

Output

      Long, l...
      Long, lon.