Skip to content

Commit 702fe9c

Browse files
committed
minor #19774 [Twig] Expand the explanation about the humanize filter (javiereguiluz)
This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [Twig] Expand the explanation about the humanize filter Fixes #19758. Commits ------- 7516215 [Twig] Expand the explanation about the humanize filter
2 parents 273581b + 7516215 commit 702fe9c

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
@@ -391,9 +391,18 @@ humanize
391391
``text``
392392
**type**: ``string``
393393

394-
Makes a technical name human readable (i.e. replaces underscores by spaces
395-
or transforms camelCase text like ``helloWorld`` to ``hello world``
396-
and then capitalizes the string).
394+
Transforms the given string into a human readable string (by replacing underscores
395+
with spaces, capitalizing the string, etc.) It's useful e.g. when displaying
396+
the names of PHP properties/variables to end users:
397+
398+
.. code-block:: twig
399+
400+
{{ 'dateOfBirth'|humanize }} {# renders: Date of birth #}
401+
{{ 'DateOfBirth'|humanize }} {# renders: Date of birth #}
402+
{{ 'date-of-birth'|humanize }} {# renders: Date-of-birth #}
403+
{{ 'date_of_birth'|humanize }} {# renders: Date of birth #}
404+
{{ 'date of birth'|humanize }} {# renders: Date of birth #}
405+
{{ 'Date Of Birth'|humanize }} {# renders: Date of birth #}
397406
398407
.. _reference-twig-filter-trans:
399408

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy