Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
glyph icon helper for twitter-bootstrap with Rails
module ApplicationHelper
# ==== Examples
# glyph(:share_alt)
# # => <i class="icon-share-alt"></i>
# glyph(:lock, :white)
# # => <i class="icon-lock icon-white"></i>
def glyph(*names)
content_tag :i, nil, class: names.map{|name| "icon-#{name.to_s.gsub('_','-')}" }
end
end

works wonderfully!

<%= link_to glyph(:pencil) + ' Edit profile', edit_user_registration_path %>
<%= link_to  glyph(:"warning-sign") + " Logout", destroy_user_session_path, method: :delete %>

Thanks, this helped me a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment