mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-13 10:56:38 +00:00
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:
committed by
Fabien Potencier
parent
af6f99f7f6
commit
cc017decd1
@@ -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*:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user