Guest User

Untitled

a guest
May 27th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. # Setting for open or closed tags by default
  2. # Rails Core seems to think XHTML is cool, hard coded defaults and all
  3. module ActionView::Helpers
  4. module TagHelper
  5.  
  6. mattr_accessor :default_tags_to_open
  7. self.default_tags_to_open = false
  8.  
  9. def tag(name, options = nil, open = ActionView::Helpers::TagHelper.default_tags_to_open, escape = true)
  10. "<#{name}#{tag_options(options, escape) if options}#{open ? ">" : " />"}".html_safe
  11. end
  12. end
  13.  
  14. module AssetTagHelper
  15. def stylesheet_tag(source, options)
  16. 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)
  17. end
  18. end
  19.  
  20. module CsrfHelper
  21. def csrf_meta_tag
  22. if protect_against_forgery?
  23. [
  24. tag('meta', :name => 'csrf-param', :content => Rack::Utils.escape_html(request_forgery_protection_token)),
  25. tag('meta', :name => 'csrf-token', :content => Rack::Utils.escape_html(form_authenticity_token)),
  26. ].join("\n").html_safe
  27. end
  28. end
  29. end
  30. end
  31.  
  32. ActionView::Helpers::TagHelper.default_tags_to_open = true
Add Comment
Please, Sign In to add comment