Sha256: 79b88ecb1b1e08481d2c45ff74811a0cde086767414f3b6561001cf10e5217f3

Contents?: true

Size: 1.75 KB

Versions: 9

Compression:

Stored size: 1.75 KB

Contents

module Html5BoilerplateHelper
  # Create a named haml tag to wrap IE conditional around a block
  # http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither
  # Consider adding an manifest.appcache: h5bp.com/d/Offline
  def ie_tag(name=:body, attrs={}, &block)
    attrs.symbolize_keys!
    haml_concat("<!--[if lt IE 7]> #{ tag(name, add_class('ie6', attrs), true) } <![endif]-->".html_safe)
    haml_concat("<!--[if IE 7]>    #{ tag(name, add_class('ie7', attrs), true) } <![endif]-->".html_safe)
    haml_concat("<!--[if IE 8]>    #{ tag(name, add_class('ie8', attrs), true) } <![endif]-->".html_safe)
    haml_concat("<!--[if gt IE 8]><!-->".html_safe)
    haml_tag name, attrs do
      haml_concat("<!--<![endif]-->".html_safe)
      block.call
    end
  end

  def ie_html(attrs={}, &block)
    ie_tag(:html, attrs, &block)
  end

  def ie_body(attrs={}, &block)
    ie_tag(:body, attrs, &block)
  end

  def google_account_id
    ENV['GOOGLE_ACCOUNT_ID'] || google_config(:google_account_id)
  end

  def google_api_key
    ENV['GOOGLE_API_KEY'] || google_config(:google_api_key)
  end

  def remote_jquery(version)
    if Rails.env == 'development'
      "'jquery', '#{version}', {uncompressed:true}"
    else
      "'jquery', '#{version}'"
    end
  end

  def local_jquery(version)
    if Rails.env == 'development'
      "#{version}/jquery.js"
    else
      "#{version}/jquery.min.js"
    end
  end

private

  def add_class(name, attrs)
    classes = attrs[:class] || ''
    classes.strip!
    classes = ' ' + classes if !classes.blank?
    classes = name + classes
    attrs.merge(:class => classes)
  end

  def google_config(key)
    configs = YAML.load_file(File.join(Rails.root, 'config', 'google.yml'))[Rails.env.to_sym] rescue {}
    configs[key]
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
compass_extension-0.1.8 lib/app/helpers/html5_boilerplate_helper.rb
compass_extension-0.1.7 lib/app/helpers/html5_boilerplate_helper.rb
compass_extension-0.1.6 lib/app/helpers/html5_boilerplate_helper.rb
compass_extension-0.1.5 lib/app/helpers/html5_boilerplate_helper.rb
compass_extension-0.1.4 lib/app/helpers/html5_boilerplate_helper.rb
compass_extension-0.1.3 lib/app/helpers/html5_boilerplate_helper.rb
compass_extension-0.1.2 lib/app/helpers/html5_boilerplate_helper.rb
compass_extension-0.1.1 lib/app/helpers/html5_boilerplate_helper.rb
html5-boilerplate-2.1.0 lib/app/helpers/html5_boilerplate_helper.rb