Created
September 25, 2013 05:16
-
-
Save takuyan/6695408 to your computer and use it in GitHub Desktop.
FontAwesomeを使うときは、ApplicationHelperにコレを登録しておくと便利。
どんどんwhen句を増やせば良い。データごとのアイコンを一元管理。 メリット:アイコン名をハードコーディングしなくて済む
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
module ApplicationHelper | |
def icon_name_for(name) | |
sym_name = name.to_sym | |
case sym_name | |
when :home | |
'icon-dashboard' | |
when :team | |
'icon-group' | |
when :content | |
'icon-pencil' | |
else | |
"icon-#{name}" | |
end | |
end | |
def icon_for(name) | |
content_tag :i, '', class: icon_name_for(name) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment