mirror of
https://github.com/Threnklyn/Klaus.git
synced 2026-05-18 12:13:28 +02:00
fügt den btn_link_to helper hinzu
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user