Skip to content

Commit

Permalink
Use sprockets helpers if config.use_sprockets is set
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Mar 29, 2011
1 parent 2b47059 commit 375443a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ def register_javascript_expansion(expansions)
# javascript_path "http://www.railsapplication.com/js/xmlhr" # => http://www.railsapplication.com/js/xmlhr
# javascript_path "http://www.railsapplication.com/js/xmlhr.js" # => http://www.railsapplication.com/js/xmlhr.js
def javascript_path(source)
asset_paths.compute_public_path(source, 'javascripts', 'js')
if config.use_sprockets
sprockets_javascript_path(source)
else
asset_paths.compute_public_path(source, 'javascripts', 'js')
end
end
alias_method :path_to_javascript, :javascript_path # aliased to avoid conflicts with a javascript_path named route

Expand Down Expand Up @@ -173,8 +177,12 @@ def javascript_path(source)
#
# javascript_include_tag :all, :cache => true, :recursive => true
def javascript_include_tag(*sources)
@javascript_include ||= JavascriptIncludeTag.new(config, asset_paths)
@javascript_include.include_tag(*sources)
if config.use_sprockets
sprockets_javascript_include_tag(*sources)
else
@javascript_include ||= JavascriptIncludeTag.new(config, asset_paths)
@javascript_include.include_tag(*sources)
end
end

end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ def register_stylesheet_expansion(expansions)
# stylesheet_path "http://www.railsapplication.com/css/style" # => http://www.railsapplication.com/css/style
# stylesheet_path "http://www.railsapplication.com/css/style.css" # => http://www.railsapplication.com/css/style.css
def stylesheet_path(source)
asset_paths.compute_public_path(source, 'stylesheets', 'css')
if config.use_sprockets
sprockets_stylesheet_path(source)
else
asset_paths.compute_public_path(source, 'stylesheets', 'css')
end
end
alias_method :path_to_stylesheet, :stylesheet_path # aliased to avoid conflicts with a stylesheet_path named route

Expand Down Expand Up @@ -136,8 +140,12 @@ def stylesheet_path(source)
# stylesheet_link_tag :all, :concat => true
#
def stylesheet_link_tag(*sources)
@stylesheet_include ||= StylesheetIncludeTag.new(config, asset_paths)
@stylesheet_include.include_tag(*sources)
if config.use_sprockets
sprockets_stylesheet_link_tag(*sources)
else
@stylesheet_include ||= StylesheetIncludeTag.new(config, asset_paths)
@stylesheet_include.include_tag(*sources)
end
end

end
Expand Down

0 comments on commit 375443a

Please sign in to comment.