Skip to content

Instantly share code, notes, and snippets.

@sstarr
Created January 18, 2013 11:17
Show Gist options
  • Save sstarr/4563999 to your computer and use it in GitHub Desktop.
Save sstarr/4563999 to your computer and use it in GitHub Desktop.
Rails helper to generate Twitter Bootstrap icons
# Generate Twitter Bootstrap icons with a minimum of fuss
# Use in views like so:
# icon('pencil') => content_tag(:i, '', class: 'icon-pencil')
# icon('trash', 'icon-white huge') => content_tag(:i, '', class: 'icon-trash icon-white huge')
def icon(style, extra_class = nil)
content_tag(:i, '', class: "icon-#{style}" + (extra_class ? " #{extra_class}" : ''))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment