Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd25c009

Browse files
committed
[Emoji][Twig] Addemojify filter
1 parent227275a commitd25c009

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

‎reference/twig_reference.rst‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,37 @@ serialize
645645
Accepts any data that can be serialized by the:doc:`Serializer component</serializer>`
646646
and returns a serialized string in the specified ``format``.
647647

648+
.. _reference-twig-filter-emojify:
649+
650+
emojify
651+
~~~~~~~
652+
653+
..versionadded::7.1
654+
655+
The ``emojify`` filter was introduced in Symfony 7.1.
656+
657+
..code-block::twig
658+
659+
{{ text|emojify(catalog = null) }}
660+
661+
``text``
662+
**type**: ``string``
663+
664+
``catalog`` *(optional)*
665+
**type**: ``string`` | ``null``
666+
667+
The emoji set used to generate the textual representation (``slack``,
668+
``github``, ``gitlab``, etc.)
669+
670+
It transforms the textual representation of an emoji (e.g. ``:wave:``) into the
671+
actual emoji (👋):
672+
673+
..code-block::twig
674+
675+
{{ ':+1:'|emojify }} {# renders: 👍 #}
676+
{{ ':+1:'|emojify('github') }} {# renders: 👍 #}
677+
{{ ':thumbsup:'|emojify('gitlab') }} {# renders: 👍 #}
678+
648679
.. _reference-twig-tags:
649680

650681
Tags

‎string.rst‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,8 @@ Convert Slack short codes to emojis with the ``slack-emoji`` locale::
613613
$transliterator->transliterate('Menus with :green_salad: or :falafel:');
614614
// => 'Menus with 🥗 or 🧆'
615615

616+
.. _string-text-emoji:
617+
616618
Universal Emoji Short Codes Transliteration
617619
###########################################
618620

@@ -637,6 +639,33 @@ You can convert emojis to short codes with the ``emoji-text`` locale::
637639
$transliterator->transliterate('Breakfast with 🥝 or 🥛');
638640
// => 'Breakfast with :kiwifruit: or :milk-glass:
639641

642+
Inverse Emoji Transliteration
643+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
644+
645+
..versionadded::7.1
646+
647+
The inverse emoji transliteration was introduced in Symfony 7.1.
648+
649+
Given the textual representation of an emoji, you can reverse it back to get the
650+
actual emoji thanks to the:ref:`emojify filter<reference-twig-filter-emojify>`:
651+
652+
..code-block::twig
653+
654+
{{ 'I like :kiwi-fruit:'|emojify }} {# renders: I like 🥝 #}
655+
{{ 'I like :kiwi:'|emojify }} {# renders: I like 🥝 #}
656+
{{ 'I like :kiwifruit:'|emojify }} {# renders: I like 🥝 #}
657+
658+
By default, ``emojify`` uses the:ref:`text catalog<string-text-emoji>`, which
659+
merges the emoji text codes of all services. If you prefer, you can select a
660+
specific catalog to use:
661+
662+
..code-block::twig
663+
664+
{{ 'I :green-heart: this'|emojify }} {# renders: I 💚 this #}
665+
{{ ':green_salad: is nice'|emojify('slack') }} {# renders: 🥗 is nice #}
666+
{{ 'My :turtle: has no name yet'|emojify('github') }} {# renders: My 🐢 has no name yet #}
667+
{{ ':kiwi: is a great fruit'|emojify('gitlab') }} {# renders: 🥝 is a great fruit #}
668+
640669
Removing Emojis
641670
~~~~~~~~~~~~~~~
642671

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp