fügt den btn_link_to helper hinzu

This commit is contained in:
Florian Bogenhard
2014-08-08 23:48:07 +02:00
parent 9c574a3003
commit 8ee68cecce
+21
View File
@@ -1,2 +1,23 @@
module ApplicationHelper
def btn_link_to(name, path, *args)
options = args.extract_options!
html_class = "btn " + (options.delete(:class) || 'btn-default')
icon = options.delete(:icon)
if icon
if icon.is_a? Hash
icon_class = icon[:class]
icon = icon[:icon]
end
span = content_tag("span", nil, class: "glyphicon glyphicon-#{icon} #{icon_class}") if icon
if name && !name.empty?
name = "#{span} #{name}".html_safe
else
name = "#{span}".html_safe
end
end
link_to name, path, {class: html_class}.update(options)
end
end