diff --git a/lib/bootstrap_helper/helper.rb b/lib/bootstrap_helper/helper.rb index 3621482..e817b68 100644 --- a/lib/bootstrap_helper/helper.rb +++ b/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