Created
June 3, 2010 10:42
-
-
Save joeljunstrom/423728 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Setting for open or closed tags by default | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment