From cc017decd1e4071f2d5303cc8dd349ae39519dc4 Mon Sep 17 00:00:00 2001 From: cavemon Date: Thu, 8 Oct 2020 16:56:24 -0700 Subject: [PATCH] Improving truncate documentation Adding description and example of third parameter for `truncate` method to preserve whole words. This seems like a common use case and extremely useful addition that should be documented. --- doc/filters/u.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/filters/u.rst b/doc/filters/u.rst index d0b787633..0946b9b2e 100644 --- a/doc/filters/u.rst +++ b/doc/filters/u.rst @@ -30,6 +30,13 @@ Truncating a string: {{ 'Lorem ipsum'|u.truncate(8, '...') }} Lorem... + +New in Symfony 5.1, the ``truncate`` method also accepts a third argument to preserve whole words: + +.. code-block:: twig + + {{ 'Lorem ipsum dolor'|u.truncate(10, '...', false) }} + Lorem ipsum... Converting a string to *snake* case or *camelCase*: