Skip to content

Commit dec8ce2

Browse files
committed
Merge branch '5.4' into 6.4
* 5.4: [Twig] Expand the explanation about the humanize filter
2 parents fe927db + 702fe9c commit dec8ce2

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

reference/twig_reference.rst

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,18 @@ humanize
416416
``text``
417417
**type**: ``string``
418418

419-
Makes a technical name human readable (i.e. replaces underscores by spaces
420-
or transforms camelCase text like ``helloWorld`` to ``hello world``
421-
and then capitalizes the string).
419+
Transforms the given string into a human readable string (by replacing underscores
420+
with spaces, capitalizing the string, etc.) It's useful e.g. when displaying
421+
the names of PHP properties/variables to end users:
422+
423+
.. code-block:: twig
424+
425+
{{ 'dateOfBirth'|humanize }} {# renders: Date of birth #}
426+
{{ 'DateOfBirth'|humanize }} {# renders: Date of birth #}
427+
{{ 'date-of-birth'|humanize }} {# renders: Date-of-birth #}
428+
{{ 'date_of_birth'|humanize }} {# renders: Date of birth #}
429+
{{ 'date of birth'|humanize }} {# renders: Date of birth #}
430+
{{ 'Date Of Birth'|humanize }} {# renders: Date of birth #}
422431
423432
.. _reference-twig-filter-trans:
424433

0 commit comments

Comments
 (0)