Module: Reusable::Rails::Helpers::Html5Helper::InstanceMethods

Defined in:
lib/reusable/rails/helpers/html5_helper.rb

Instance Method Summary collapse

Instance Method Details

#google_account_idString

Fetch the Google Account ID for this application from either the ‘GOOGLE_ACCOUNT_ID’ environment variable or from the config/google.yml file.

Returns:

  • (String)

See Also:

  • #google_config


39
40
41
# File 'lib/reusable/rails/helpers/html5_helper.rb', line 39

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

#google_api_keyString

Fetch the Google API ID for this application from either the ‘GOOGLE_API_ID’ environment variable or from the config/google.yml file.

Returns:

  • (String)

See Also:

  • #google_config


49
50
51
# File 'lib/reusable/rails/helpers/html5_helper.rb', line 49

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

#google_cdn_jquery(version = '1.6.2') ⇒ String

Generates the Google API code for serving jQuery either compressed or uncompressed.

Parameters:

  • jQuery (String)

    version number

Returns:

  • (String)

    Google API string



58
59
60
61
62
63
64
# File 'lib/reusable/rails/helpers/html5_helper.rb', line 58

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

#ie_body(attrs = {}, &block) ⇒ Object



29
30
31
# File 'lib/reusable/rails/helpers/html5_helper.rb', line 29

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

#ie_html(attrs = {}, &block) ⇒ Object



25
26
27
# File 'lib/reusable/rails/helpers/html5_helper.rb', line 25

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

#ie_tag(name = :body, attrs = {}, &block) ⇒ Object

Create a named haml tag to wrap IE conditional around a block paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/reusable/rails/helpers/html5_helper.rb', line 13

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

#remote_jquery(version = '1.6.2') ⇒ String

Generates the jQuery file extension for including jQuery from the Google CDN

Parameters:

  • jQuery (String)

    version number

Returns:

  • (String)


71
72
73
74
75
76
77
# File 'lib/reusable/rails/helpers/html5_helper.rb', line 71

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