2009-02-27 61 views

回答

5

这个答案包含在由MarkusQ提供的链接,但我想我可以把它拼出来。

您必须修改比呈现所有标签的代码,你可以做到这一点,包括下面的代码到类似的lib/dont_use_xhtml.rb

module ActionView::Helpers::TagHelper 
    alias :tag_without_backslash :tag 
    def tag(name, options = nil, open = true, escape = true) 
     tag_without_backslash(name, options, open, escape) 
    end 
    end 
2

的解决方案不使用Rails的最新版本工作。有些助手会将open方法的参数'open'重写为'false'。在Rails的2.3.5我

以下工作:

module ActionView::Helpers::TagHelper 
    def tag_with_html_patch(name, options = nil, open = true, escape = true) 
    tag_without_html_patch(name, options, true, escape) 
    end 
    alias_method_chain :tag, :html_patch 
end 

它放入一个初始化。

0

钢轨2.3

安装宝石haml然后添加以下初始化config/initializers/force_html4.rb

Haml::Template::options[:format] = :html4 

module StandardistaHelper 
    def tag(name, options = nil, open = false, escape = true) 
    "<#{name}#{tag_options(options, escape) if options}>" 
    end 
end 

ActionView::Base.send :include, StandardistaHelper 

ActionView::Helpers::InstanceTag.class_eval do 
    def tag_without_error_wrapping(name, options = nil, open = false, escape = true) 
    "<#{name}#{tag_options(options, escape) if options}>" 
    end 
end