- Notifications
You must be signed in to change notification settings - Fork791
github/gemoji
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This library contains character information about native emojis.
Addgemoji to your Gemfile.
gem'gemoji'
This would allow emojifying content such as:it's raining :cat:s and :dog:s!
See theEmoji cheat sheet for more examples.
moduleEmojiHelperdefemojify(content)h(content).to_str.gsub(/:([\w+-]+):/)do |match|ifemoji=Emoji.find_by_alias($1)%(<img alt="#$1" src="#{image_path("emoji/#{emoji.image_filename}")}" width="20" height="20" />)elsematchendend.html_safeifcontent.present?endend
Translate emoji names to unicode and vice versa.
>>Emoji.find_by_alias("cat").raw=>"🐱"# Don't see a cat? That's U+1F431.>>Emoji.find_by_unicode("\u{1f431}").name=>"cat"
You can add new emoji characters to theEmoji.all list:
emoji=Emoji.create("music")do |char|char.add_alias"song"char.add_unicode_alias"\u{266b}"char.add_tag"notes"endemoji.name#=> "music"emoji.raw#=> "♫"emoji.image_filename#=> "unicode/266b.png"# Creating custom emoji (no Unicode aliases):emoji=Emoji.create("music")do |char|char.add_tag"notes"endemoji.custom?#=> trueemoji.image_filename#=> "music.png"
As you create new emoji, you must ensure that you also create and put the imagesthey reference by theirimage_filename to your assets directory.
You can customizeimage_filename with:
emoji=Emoji.create("music")do |char|char.image_filename="subdirectory/my_emoji.gif"end
For existing emojis, you can edit the list of aliases or add new tags in an edit block:
emoji=Emoji.find_by_alias"musical_note"Emoji.edit_emoji(emoji)do |char|char.add_alias"music"char.add_unicode_alias"\u{266b}"char.add_tag"notes"endEmoji.find_by_alias"music"#=> emojiEmoji.find_by_unicode"\u{266b}"#=> emoji
About
Emoji images and names.
Topics
Resources
License
Code of conduct
Contributing
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published