Module: Xebec::HTML5
- Included in:
- NavBarHelper
- Defined in:
- lib/xebec/html5.rb
Overview
Xebec will help you transition your site to HTML 5 by using the <nav>
element like so:
<nav class='my_navbar_name'>
<ul>
<li><a href='/home'>Home</a></li>
...
</ul>
</nav>
Most browsers are perfectly happy with the <nav>
element, but Internet Explorer (all current versions) behaves… oddly. Specifically, IE will treat the above HTML as though it were really this:
<nav class='my_navbar_name'>
</nav>
<ul>
<li><a href='/home'>Home</a></li>
...
</ul>
That, unfortunately messes with your CSS selectors. Xebec, therefore, has a slightly more intelligent default behavior. If it detects a browser that does not support HTML5 elements, it will replace the <nav>
element with a <div class='navbar'>
.
Some enterprising folks have found a workaround for IE, however. If you really want to use the <nav>
element for all browsers, do two things:
-
in config/environment.rb, call
Xebec.html5_for_all_browsers!
-
in the
<head>
tag in your site layout, call<%= add_html5_dom_elements_to_ie %>
See also the example application.
Constant Summary collapse
- NON_HTML_5_USER_AGENTS =
/msie/i
Class Attribute Summary collapse
-
.force ⇒ Object
Returns the value of attribute force.
Instance Method Summary collapse
Class Attribute Details
.force ⇒ Object
Returns the value of attribute force.
50 51 52 |
# File 'lib/xebec/html5.rb', line 50 def force @force end |
Instance Method Details
#user_agent_supports_html5? ⇒ Boolean
56 57 58 59 |
# File 'lib/xebec/html5.rb', line 56 def user_agent_supports_html5? return true if Xebec::HTML5.force return !(NON_HTML_5_USER_AGENTS === request.user_agent) end |