Method: Sprockets::Helpers#javascript_path
- Defined in:
- lib/sprockets/helpers.rb
#javascript_path(source, options = {}) ⇒ Object Also known as: path_to_javascript
Computes the path to a javascript asset either in the Sprockets environment or the public directory. If the source filename has no extension, .js will be appended. External URIs are untouched.
Examples
For files within Sprockets:
javascript_path 'xmlhr' # => '/assets/xmlhr.js'
javascript_path 'dir/xmlhr.js' # => '/assets/dir/xmlhr.js'
javascript_path '/dir/xmlhr' # => '/assets/dir/xmlhr.js'
For files outside of Sprockets:
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'
234 235 236 |
# File 'lib/sprockets/helpers.rb', line 234 def javascript_path(source, = {}) asset_path source, sprockets_helpers_settings.[:javascript_path].merge() end |