Skip to content
Browse files

Added buttons helpers, usage:

btn 'A text', a_path_helper, class: 'my-class', ...
btn_primary 'A text', a_path_helper, class: 'my-class', ...
btn_danger 'A text', a_path_helper, class: 'my-class', ...
... is intended for additional options
  • Loading branch information...
1 parent 6f107b8 commit de4beec0ab648204b4b8ec6974eb7a6525d3962e juan david pastas committed Jul 11, 2012
Showing with 11 additions and 0 deletions.
  1. +11 −0 lib/bootstrap_helper/helper.rb
View
11 lib/bootstrap_helper/helper.rb
@@ -145,6 +145,17 @@ def render_list(list=[], options={})
return ul.to_s
end
+
+ def btn(text, path, type = '', options={})
+ css = options.delete(:class) || options.delete('class')
+ link_to text, path, {class: 'btn ' + type + ' ' + css}.merge(options)
+ end
+
+ %w(primary info success warning danger inverse).each do |type|
+ define_method 'btn_' + type do |text, path, options = {}|
+ btn text, path, 'btn-' + type, options
+ end
+ end
# Composite pattern
class TagNode

0 comments on commit de4beec

Please sign in to comment.
Something went wrong with that request. Please try again.