Configure Rails to output HTML output instead of XHTML

后端 未结 4 2070
说谎
说谎 2021-02-04 16:34

How do I configure Ruby on Rails to output standard HTML code instead of XHTML when using helpers (form, javascript, css, etc.)?

I don\'t want to have t

4条回答
  •  感动是毒
    2021-02-04 17:23

    For rails 2.3:

    Install the gem haml then add the following initializer 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
    

提交回复
热议问题