Forked from frankie-loves-jesus/application_helper.rb
Last active
August 29, 2015 14:06
-
-
Save universal/1caf2f6cca59c3d1e902 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def add_emojify_and_kramdown(text) | |
| markdowned = Kramdown::Document.new(text).to_html | |
| raw(emojify(markdowned)) | |
| end | |
| def emojify(text) | |
| text.to_str.gsub(/:([a-z0-9\+\-_]+):/) do |match| | |
| if emoji = Emoji.find_by_alias($1) | |
| %Q{<img alt="$1" class="emoji" src="#{ image_path(emoji.image_filename) }">} | |
| else | |
| match | |
| end | |
| end | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment