Module: Xebec::NavBarHelper

Includes:
HTML5, HasNavBars
Defined in:
lib/xebec/nav_bar_helper.rb

Constant Summary

Constants included from HTML5

HTML5::NON_HTML_5_USER_AGENTS

Instance Method Summary collapse

Methods included from HTML5

#user_agent_supports_html5?

Instance Method Details

#add_html5_dom_elements_to_ieObject

Renders a <script> tag that preloads HTML5 tags in IE. Useful if you called Xebec.html5_for_all_browsers! in your environment.rb.

See Also:



54
55
56
57
58
59
60
# File 'lib/xebec/nav_bar_helper.rb', line 54

def add_html5_dom_elements_to_ie
  return <<-EOS
<!--[if lt IE 9]>
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
EOS
end

If called in an output expression (“<%= navbar %>” in ERB or “=navbar” in HAML), renders the navigation bar.

If called with a block, yields the underlying NavBar for modification.

Examples:

<%= navbar :tabs %>
# => <ul class="navbar tabs">...</ul>
<% navbar do |nb|
  nb.nav_item :home
  nb.nav_item :faq, pages_path(:page => :faq)
end %>

Returns:

See Also:



34
35
36
# File 'lib/xebec/nav_bar_helper.rb', line 34

def nav_bar(name = nil, html_attributes = {}, options = {}, &block)
  look_up_nav_bar_and_eval name, html_attributes, options, &block
end

Renders a navigation bar if and only if it contains any navigation items. Unlike nav_bar, this method does not accept a block.

Returns:



43
44
45
46
# File 'lib/xebec/nav_bar_helper.rb', line 43

def nav_bar_unless_empty(name = nil, html_attributes = {})
  bar = look_up_nav_bar name, html_attributes
  bar.empty? ? '' : bar
end