Skip to content
This repository has been archived by the owner on Sep 24, 2019. It is now read-only.

Commit

Permalink
Don't put in self-closing tags on anything.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmorrison committed Apr 4, 2009
1 parent 5820bcc commit 6917496
Showing 1 changed file with 13 additions and 25 deletions.
38 changes: 13 additions & 25 deletions lib/html5.rb
Expand Up @@ -16,32 +16,20 @@ def javascript_src_tag_with_empty_type(source, options)
def stylesheet_tag(source, options)
tag("link", { "rel" => "stylesheet", "media" => "screen", "href" => html_escape(path_to_stylesheet(source)) }.merge(options), ::SKIP_SELF_CLOSE_TAGS, false)
end

def image_tag(source, options = {})
options.symbolize_keys!

options[:src] = path_to_image(source)
options[:alt] ||= File.basename(options[:src], '.*').split('.').first.to_s.capitalize

if size = options.delete(:size)
options[:width], options[:height] = size.split("x") if size =~ %r{^\d+x\d+$}
end
end

if mouseover = options.delete(:mouseover)
options[:onmouseover] = "this.src='#{image_path(mouseover)}'"
options[:onmouseout] = "this.src='#{image_path(options[:src])}'"
end

tag("img", options, ::SKIP_SELF_CLOSE_TAGS)
end
module ActionView::Helpers::TagHelper
# When served as text/html, tags do not need to be self-closed.
# http://www.whatwg.org/specs/web-apps/current-work/#void-elements
VOID_ELEMENTS = %w(base command link meta hr br img embed param area col input source)
def tag_with_skip_self_closing(name, options = nil, open = false, escape = true)
open = true if VOID_ELEMENTS.include?(name.to_s) && ::SKIP_SELF_CLOSE_TAGS

def auto_discovery_link_tag(type = :rss, url_options = {}, tag_options = {})
tag(
"link",
{"rel" => tag_options[:rel] || "alternate",
"type" => tag_options[:type] || Mime::Type.lookup_by_extension(type.to_s).to_s,
"title" => tag_options[:title] || type.to_s.upcase,
"href" => url_options.is_a?(Hash) ? url_for(url_options.merge(:only_path => false)) : url_options}, ::SKIP_SELF_CLOSE_TAGS
)
tag_without_skip_self_closing(name, options, open, escape)
end
end
alias_method_chain :tag, :skip_self_closing
end


0 comments on commit 6917496

Please sign in to comment.