Method: Storefront::Components::Button#initialize
- Defined in:
- lib/storefront/components/button.rb
#initialize(*args, &block) ⇒ Button
Returns a new instance of Button.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/storefront/components/button.rb', line 4 def initialize(*args, &block) attributes = args. label = args.shift path = args.shift tag = attributes.delete(:as) inner_html = attributes.delete(:inner_html) || {} outer_html = attributes.delete(:outer_html) || {} inner_html.merge! clone_attributes(attributes) outer_html.merge! clone_attributes(attributes.except(:rel, :target)) merge_class! outer_html, "button" capture_haml do haml_tag :div, :<, outer_html do result = succeed "<span></span>".html_safe do if block_given? haml_concat capture_haml(&block).gsub("\n", "").strip else if tag haml_tag tag, :>, :<, inner_html else haml_concat link_to(label, path, inner_html) end end end haml_concat result end end end |