views:

208

answers:

2

I would like to use HTML 4.01 Strict, and used a DOCTYPE of it in my application template. But look like when a style sheet is included by a helper function

<%= stylesheet_link_tag 'style' %>

the code produced is XHTML:

<link href="/stylesheets/style.css?1243210734" media="screen" rel="stylesheet" type="text/css" />

is there a way to ask Rails to produce HTML instead of XHTML? (so that the HTML will validate for example)

A: 

Not really, no.

Edit: in line with my comment below, this should work (I still feel uneasy, but I can't think of anything that will break because of this)

module ActionView::Helpers::TagHelper
  def tag_with_html(name, options = nil, open, escape = true)
    tag_without_html(name, options, true, escape)
  end
  alias_method_chain :tag, :html
end
there was an old post, i later found: http://stackoverflow.com/questions/595867/configure-rails-to-output-html-output-instead-of-xhtml but the solution seems a bit hacky...
動靜能量
The problem with these solutions, both the one in stackoverflow and the one on railsforum is that they're just providing a default value for the `open` argument. Plenty of Rails helpers explicitly set this to false, so the default will have no effect.Come to think of it though, in HTML there's NEVER a need to have a self-closing tag. So actually the examples should work if you actually just override the `close` parameter to ALWAYS be false.
+1  A: 

Just a quick fix to the included code above, which does work.

module ActionView::Helpers::TagHelper
  def tag_with_html(name, options = nil, open = true, escape = true)
    tag_without_html(name, options, true, escape)
  end
  alias_method_chain :tag, :html
end

Thanks for the tip!

Seth Ladd