Module: RailsHTMLHelpers::Rails::Helpers
- Defined in:
- lib/rails_html_helpers/rails/helpers.rb
Instance Method Summary collapse
-
#body_class(c = nil) ⇒ String
Sets body classes.
-
#html_tag(attrs = {}, &block) ⇒ String
Helper to display conditional html tags for IE.
-
#title(t = nil, separator = " | ") ⇒ String
Sets and formats document title.
Instance Method Details
#body_class(c = nil) ⇒ String
Sets body classes
21 22 23 24 25 |
# File 'lib/rails_html_helpers/rails/helpers.rb', line 21 def body_class(c = nil) @body_class ||= [controller.controller_name] @body_class << c @body_class.flatten.compact.uniq.join(" ") end |
#html_tag(attrs = {}, &block) ⇒ String
Helper to display conditional html tags for IE
paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither has been originally lifted from the HTML5-rails gem: raw.github.com/sporkd/html5-rails/master/lib/html5/rails/helpers.rb
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rails_html_helpers/rails/helpers.rb', line 36 def html_tag(attrs = {}, &block) attrs.symbolize_keys! html = "<!--[if lt IE 7]> #{ tag(:html, add_class('no-js lt-ie9 lt-ie8 lt-ie7', attrs), true) } <![endif]-->\n" html << "<!--[if IE 7]> #{ tag(:html, add_class('no-js lt-ie9 lt-ie8', attrs), true) } <![endif]-->\n" html << "<!--[if IE 8]> #{ tag(:html, add_class('no-js lt-ie9', attrs), true) } <![endif]-->\n" html << "<!--[if gt IE 8]><!--> " if block_given? && defined? Haml haml_concat(html.html_safe) haml_tag :html, add_class('no-js', attrs) do haml_concat("<!--<![endif]-->".html_safe) yield end else html = html.html_safe html << tag(:html, add_class('no-js', attrs), true) html << " <!--<![endif]-->\n".html_safe html end end |
#title(t = nil, separator = " | ") ⇒ String
Sets and formats document title
10 11 12 13 14 |
# File 'lib/rails_html_helpers/rails/helpers.rb', line 10 def title(t = nil, separator = " | ") @title ||= [] @title << t @title.flatten.compact.join(separator) end |