public
Description: Plugin for Rails to render HTML tags instead of XHTML tags.
Homepage:
Clone URL: git://github.com/napcs/html_tags.git
Brian Hogan (author)
Thu May 28 07:57:09 -0700 2009
commit  67565b6df6ecb9f72a7c1bc2cceb8a1acc2f543f
tree    15246d809df2b3624d4f51a2a3653e8f7d2df744
parent  45d44bca44e8cc09bc7ecab3e90c8ad8eb11da95
README.rdoc

html_tags

Makes Rails helpers generate tags in HTML syntax instead of the XHTML 1.0 syntax it uses.

Why whould I want to do this?

The reasons for using HTML 4.01 Strict instead of XHTML 1.0 Transitional or XHTML 1.0 Strict are well-documented, but here are some reasons for using HTML:

  • The W3C currently recommends serving web page documents as HTML 4.01 Strict, due to several probelsm with XHTML.
  • Most web servers serve XHTML documents as text/html rather than application/xhtml+xml. This is often done because, unfortunately, Microsoft Internet Explorer 6, 7, and 8 cannot accept the media type application/xhtml+xml.
  • When you serve your XHTML syntax based documents as text/html they will be treated as HTML by the browser. The browser sees tag soup, and has to fix it on the fly. Even though your document is valid, it doesn’t matter to the browser. This wastes users’ time.

XHTML provides no real benefits to those developing web-based applications, and can in some cases create some serious headaches. Solutions like content negotiation, browser detection, etc are unnecessary if you simply serve valid, strict HTML.

This also prepares us for HTML 5, which is quite nice.

Further reading

Usage

Just install the plugin.

  ruby script/plugin install git://github.com/napcs/html_tags

The helpers are overridden to generate appropriate HTML syntax. Generally, this means no self-closing tags.

  • input no longer self-closes
  • img no longer self-closes
  • link no longer self-closes

Issues

I haven’t created tests for every possible tag case yet, but we have a start.

I’m also a little uncomfortable with the way this hacks the internals of Rails. I’ll keep looking for better ways. Please fork, patch, and send back!

Copyright © 2009 Brian Hogan, released under the MIT license