aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/helpers/asset_tag_helper.rb
diff options
context:
space:
mode:
authorNathan Stitt <nathan@stitt.org>2013-08-01 13:10:36 -0500
committerNathan Stitt <nathan@stitt.org>2013-08-03 09:30:06 -0500
commit0855f041df5a46c2f3fd0820864e4139eb37a6c4 (patch)
tree602422e6fab7cb03434cb82e073111669e0bc97a /actionview/lib/action_view/helpers/asset_tag_helper.rb
parent51c61cfbc8ade02afbda319f9a61dda65dcb98ec (diff)
downloadrails-0855f041df5a46c2f3fd0820864e4139eb37a6c4.tar.gz
rails-0855f041df5a46c2f3fd0820864e4139eb37a6c4.tar.bz2
rails-0855f041df5a46c2f3fd0820864e4139eb37a6c4.zip
Add "extname" option to javascript_include_tag
ActionView::Helpers.asset_path is where the logic for javascript_include_tag resides. It takes an extname option for specifying the extension or false to not append it. This exposes that option to javascript_include_tag. Without the option files that didn't end with ".js" would get the extension appended to them. This broke JST templates and other file types that should be interpreted as JavaScript but who's file extension isn't ".js"
Diffstat (limited to 'actionview/lib/action_view/helpers/asset_tag_helper.rb')
-rw-r--r--actionview/lib/action_view/helpers/asset_tag_helper.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/actionview/lib/action_view/helpers/asset_tag_helper.rb b/actionview/lib/action_view/helpers/asset_tag_helper.rb
index 2b3a3c6a29..a13d0021ea 100644
--- a/actionview/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionview/lib/action_view/helpers/asset_tag_helper.rb
@@ -26,7 +26,8 @@ module ActionView
# to <tt>assets/javascripts</tt>, full paths are assumed to be relative to the document
# root. Relative paths are idiomatic, use absolute paths only when needed.
#
- # When passing paths, the ".js" extension is optional.
+ # When passing paths, the ".js" extension is optional. If you do not want ".js"
+ # appended to the path <tt>extname: false</tt> can be set on the options.
#
# You can modify the HTML attributes of the script tag by passing a hash as the
# last argument.
@@ -37,6 +38,9 @@ module ActionView
# javascript_include_tag "xmlhr"
# # => <script src="/assets/xmlhr.js?1284139606"></script>
#
+ # javascript_include_tag "template.jst", extname: false
+ # # => <script src="/assets/template.jst?1284139606"></script>
+ #
# javascript_include_tag "xmlhr.js"
# # => <script src="/assets/xmlhr.js?1284139606"></script>
#
@@ -51,8 +55,7 @@ module ActionView
# # => <script src="http://www.example.com/xmlhr.js"></script>
def javascript_include_tag(*sources)
options = sources.extract_options!.stringify_keys
- path_options = options.extract!('protocol').symbolize_keys
-
+ path_options = options.extract!('protocol', 'extname').symbolize_keys
sources.uniq.map { |source|
tag_options = {
"src" => path_to_javascript(source, path_options)