Created
January 14, 2010 17:55
-
-
Save jszmajda/277348 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
# in lib/asset_tag_helper_ext.rb | |
module ActionView | |
module Helpers | |
module AssetTagHelper | |
alias :orig_javascript_include_tag :javascript_include_tag | |
def javascript_include_tag(*sources) | |
options = sources.extract_options!.stringify_keys | |
rkey = '__scripts' | |
request[rkey] ||= [] | |
scripts = request[rkey] | |
ok = [] | |
sources.each do |src| | |
if !scripts.include?(src.to_s) | |
scripts << src.to_s | |
ok << src | |
end | |
end | |
request[rkey] = scripts | |
orig_javascript_include_tag(ok, options) | |
end | |
alias :orig_stylesheet_link_tag :stylesheet_link_tag | |
def stylesheet_link_tag(*sources) | |
options = sources.extract_options!.stringify_keys | |
rkey = '__styles' | |
request[rkey] ||= [] | |
styles = request[rkey] | |
ok = [] | |
sources.each do |src| | |
if !styles.include?(src.to_s) | |
styles << src.to_s | |
ok << src | |
end | |
end | |
request[rkey] = styles | |
orig_stylesheet_link_tag(ok, options) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment