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.
This commit is contained in:
cavemon
2020-10-08 16:56:24 -07:00
committed by Fabien Potencier
parent af6f99f7f6
commit cc017decd1
+7
View File
@@ -31,6 +31,13 @@ Truncating a string:
{{ 'Lorem ipsum'|u.truncate(8, '...') }} {{ 'Lorem ipsum'|u.truncate(8, '...') }}
Lorem... 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*: Converting a string to *snake* case or *camelCase*:
.. code-block:: twig .. code-block:: twig