Last active
August 29, 2015 14:12
-
-
Save illoyd/5aeddfddc013d9eac63c to your computer and use it in GitHub Desktop.
Bootstrap and Rails Helpers
This file contains 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
## | |
# Prefix a string with an icon | |
def iconify(label, icon, options = {}) | |
"#{ icon(icon, options) } #{ label }".strip.html_safe | |
end | |
## | |
# Create a label | |
def llabel(text, kind = :default) | |
content_tag(:span, text, class: [ 'label', "label-#{ kind }" ].compact) | |
end |
This file contains 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
## | |
# Create a font-awesome icon | |
def icon( kind = :blank, options = {} ) | |
kind = ICONS.fetch(kind, kind.to_s.gsub(/_/, '-')) | |
options[:class] = [ 'fa', "fa-#{kind}", options[:class] ].compact | |
content_tag(:i, '', options) | |
end | |
def favorite_icon(toggle) | |
icon(toggle ? :star : 'star-o') | |
end |
This file contains 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
## | |
# Create a Glyphicon icon | |
def icon( kind = :blank, options = {} ) | |
kind = ICONS.fetch(kind, kind.to_s.gsub(/_/, '-')) | |
options[:class] = [ 'glyphicon', "glyphicon-#{kind}", options[:class] ].compact | |
content_tag(:i, '', options) | |
end | |
def favorite_icon(toggle) | |
icon(toggle ? :star : 'star-empty') | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment