Skip to content

Commit

Permalink
Merge branch '7.0' into 7.1
Browse files Browse the repository at this point in the history
* 7.0:
  [Twig] Expand the explanation about the humanize filter
  • Loading branch information
javiereguiluz committed Apr 12, 2024
2 parents 7de0684 + b69a44d commit f561ae6
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions reference/twig_reference.rst
Expand Up @@ -408,9 +408,18 @@ humanize
``text``
**type**: ``string``

Makes a technical name human readable (i.e. replaces underscores by spaces
or transforms camelCase text like ``helloWorld`` to ``hello world``
and then capitalizes the string).
Transforms the given string into a human readable string (by replacing underscores
with spaces, capitalizing the string, etc.) It's useful e.g. when displaying
the names of PHP properties/variables to end users:

.. code-block:: twig
{{ 'dateOfBirth'|humanize }} {# renders: Date of birth #}
{{ 'DateOfBirth'|humanize }} {# renders: Date of birth #}
{{ 'date-of-birth'|humanize }} {# renders: Date-of-birth #}
{{ 'date_of_birth'|humanize }} {# renders: Date of birth #}
{{ 'date of birth'|humanize }} {# renders: Date of birth #}
{{ 'Date Of Birth'|humanize }} {# renders: Date of birth #}
.. _reference-twig-filter-trans:

Expand Down

0 comments on commit f561ae6

Please sign in to comment.