Skip to content

Commit b69a44d

Browse files
committed
Merge branch '6.4' into 7.0
* 6.4: [Twig] Expand the explanation about the humanize filter
2 parents d13e38c + dec8ce2 commit b69a44d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

reference/twig_reference.rst

+12-3
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,18 @@ humanize
408408
``text``
409409
**type**: ``string``
410410

411-
Makes a technical name human readable (i.e. replaces underscores by spaces
412-
or transforms camelCase text like ``helloWorld`` to ``hello world``
413-
and then capitalizes the string).
411+
Transforms the given string into a human readable string (by replacing underscores
412+
with spaces, capitalizing the string, etc.) It's useful e.g. when displaying
413+
the names of PHP properties/variables to end users:
414+
415+
.. code-block:: twig
416+
417+
{{ 'dateOfBirth'|humanize }} {# renders: Date of birth #}
418+
{{ 'DateOfBirth'|humanize }} {# renders: Date of birth #}
419+
{{ 'date-of-birth'|humanize }} {# renders: Date-of-birth #}
420+
{{ 'date_of_birth'|humanize }} {# renders: Date of birth #}
421+
{{ 'date of birth'|humanize }} {# renders: Date of birth #}
422+
{{ 'Date Of Birth'|humanize }} {# renders: Date of birth #}
414423
415424
.. _reference-twig-filter-trans:
416425

0 commit comments

Comments
 (0)