Sha256: cc8c8fce723d4866d0cb3a94d42dc63eb9c5f21e7820cc922050f2aa0086adec

Contents?: true

Size: 1.4 KB

Versions: 5

Compression:

Stored size: 1.4 KB

Contents

module Storefront
  # Encapsulates common browser hacks
  module ComponentHelper
    def rich_image_tag(label, path, options = {})
      capture_haml do
        haml_tag :span
        haml_concat image_tag(label, path, options)
      end
    end
    
    def rich_button(*args, &block)
      attributes = args.extract_options!
      label = args.shift
      path  = args.shift
      tag   = attributes.delete(:as)
    
      #locale_options = attributes.delete(:locale_options) || {}
      #label          = t?(label, locale_options.reverse_merge(:scope => :"buttons"))
    
      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
  
    def rich_input(*args, &block)
    
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
storefront-0.3.2 lib/storefront/helpers/component_helper.rb
storefront-0.3.1 lib/storefront/helpers/component_helper.rb
storefront-0.3.0 lib/storefront/helpers/component_helper.rb
storefront-0.2.8 lib/storefront/helpers/component_helper.rb
storefront-0.2.7 lib/storefront/helpers/component_helper.rb