Method: ActionView::Helpers::AssetTagHelper::JavascriptTagHelpers#javascript_path

Defined in:
lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb

#javascript_path(source) ⇒ Object Also known as: path_to_javascript

Computes the path to a javascript asset in the public javascripts directory. If the source filename has no extension, .js will be appended (except for explicit URIs) Full paths from the document root will be passed through. Used internally by javascript_include_tag to build the script path.

Examples

javascript_path "xmlhr"                              # => /javascripts/xmlhr.js
javascript_path "dir/xmlhr.js"                       # => /javascripts/dir/xmlhr.js
javascript_path "/dir/xmlhr"                         # => /dir/xmlhr.js
javascript_path "http://www.example.com/js/xmlhr"    # => http://www.example.com/js/xmlhr
javascript_path "http://www.example.com/js/xmlhr.js" # => http://www.example.com/js/xmlhr.js


85
86
87
# File 'lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb', line 85

def javascript_path(source)
  asset_paths.compute_public_path(source, 'javascripts', :ext => 'js')
end