module RailsHTMLHelpers::Rails::Helpers
Public Instance Methods
body_class(c = nil)
click to toggle source
Sets body classes
@param [Mixed] @return [String] CSS classes
# 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 = {}) { || ... }
click to toggle source
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
@param [Hash] Attributes hash for HTML tag @return [String] HTML
# 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 = " | ")
click to toggle source
Sets and formats document title
@param [Mixed] @param [String] Separator @return [String] Title
# File lib/rails_html_helpers/rails/helpers.rb, line 10 def title(t = nil, separator = " | ") @title ||= [] @title << t @title.flatten.compact.join(separator) end
Private Instance Methods
add_class(name, attrs)
click to toggle source
# File lib/rails_html_helpers/rails/helpers.rb, line 59 def add_class(name, attrs) classes = attrs[:class] || '' classes.strip! classes = ' ' + classes if !classes.empty? classes = name + classes attrs.merge(:class => classes) end