Print Directives

Print directives are post-processing on the output of a print command.

The table below lists basic print directives that are available by default. For print directives related to bidirectional text, see Bidi Support. For information on writing custom print directives, see Plugins.

Directive Usage

Changes newlines (\n, \r, or \r\n) to <br>s.


Truncates a string to a maximum length n with trailing ellipsis. Add the optional ,false to truncate without an ellipsis. For example, 'Lorem Ipsum' |truncate:8 produces Lorem..., while 'Lorem Ipsum' |truncate:8,false produces Lorem Ip.

Note: Simple truncation does not guarantee consistent visual results. For example, in common fonts, the character "x" is about half the width of a Chinese character, and "l" is half that. It's better to use CSS size constraints and text-overflow: ellipsis when possible.