Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Setting for open or closed tags by default
- # Rails Core seems to think XHTML is cool, hard coded defaults and all
- module ActionView::Helpers
- module TagHelper
- mattr_accessor :default_tags_to_open
- self.default_tags_to_open = false
- def tag(name, options = nil, open = ActionView::Helpers::TagHelper.default_tags_to_open, escape = true)
- "<#{name}#{tag_options(options, escape) if options}#{open ? ">" : " />"}".html_safe
- end
- end
- module AssetTagHelper
- def stylesheet_tag(source, options)
- tag("link", { "rel" => "stylesheet", "type" => Mime::CSS, "media" => "screen", "href" => html_escape(path_to_stylesheet(source)) }.merge(options), ActionView::Helpers::TagHelper.default_tags_to_open, false)
- end
- end
- module CsrfHelper
- def csrf_meta_tag
- if protect_against_forgery?
- [
- tag('meta', :name => 'csrf-param', :content => Rack::Utils.escape_html(request_forgery_protection_token)),
- tag('meta', :name => 'csrf-token', :content => Rack::Utils.escape_html(form_authenticity_token)),
- ].join("\n").html_safe
- end
- end
- end
- end
- ActionView::Helpers::TagHelper.default_tags_to_open = true
Add Comment
Please, Sign In to add comment