Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Buttons helpers #11

Open
wants to merge 2 commits into from

1 participant

@juanpastas

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

juan david p... added some commits
juan david pastas 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
de4beec
juan david pastas fixed when options[:class] is nil 1eb0e5b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 11, 2012
  1. Added buttons helpers, usage:

    juan david pastas authored
    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
  2. fixed when options[:class] is nil

    juan david pastas authored
This page is out of date. Refresh to see the latest.
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')).to_s
+ 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
Something went wrong with that request. Please try again.