Skip to content

Instantly share code, notes, and snippets.

@universal
Forked from frankie-loves-jesus/application_helper.rb
Last active August 29, 2015 14:06
Show Gist options
  • Select an option

  • Save universal/1caf2f6cca59c3d1e902 to your computer and use it in GitHub Desktop.

Select an option

Save universal/1caf2f6cca59c3d1e902 to your computer and use it in GitHub Desktop.
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