minor #3407 Improving truncate documentation (cavemon)

This PR was submitted for the 3.x branch but it was merged into the 2.x branch instead.

Discussion
----------

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.

Commits
-------

cc017dec Improving truncate documentation
This commit is contained in:
Fabien Potencier
2020-10-14 08:37:17 +02:00
+7
View File
@@ -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*: