diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-08-06 13:48:59 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-08-06 13:48:59 -0700 |
commit | 9cd1f697f1b4dded0f18e13c7ae12c7bd2dab1c0 (patch) | |
tree | 6a264a6b79db52141187d32434211943e5a94d93 /actionpack/lib | |
parent | 02d31841bcf317d79925ca82dcc1bbf9079dc659 (diff) | |
parent | 0c4c7d94ed3e16a206bceced679fa129c9a254b8 (diff) | |
download | rails-9cd1f697f1b4dded0f18e13c7ae12c7bd2dab1c0.tar.gz rails-9cd1f697f1b4dded0f18e13c7ae12c7bd2dab1c0.tar.bz2 rails-9cd1f697f1b4dded0f18e13c7ae12c7bd2dab1c0.zip |
Merge pull request #7277 from sikachu/master-js-include-tag-fix
Do not include application.js if it doesn't exists
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb b/actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb index 14d62af67b..139f4d19ab 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb @@ -26,7 +26,8 @@ module ActionView def expand_sources(sources, recursive = false) if sources.include?(:all) - all_asset_files = (collect_asset_files(custom_dir, ('**' if recursive), "*.#{extension}") - ['application']) << 'application' + all_asset_files = (collect_asset_files(custom_dir, ('**' if recursive), "*.#{extension}") - ['application']) + add_application_js(all_asset_files, sources) ((determine_source(:defaults, expansions).dup & all_asset_files) + all_asset_files).uniq else expanded_sources = sources.inject([]) do |list, source| @@ -39,7 +40,7 @@ module ActionView end def add_application_js(expanded_sources, sources) - if sources.include?(:defaults) && File.exist?(File.join(custom_dir, "application.#{extension}")) + if (sources.include?(:defaults) || sources.include?(:all)) && File.exist?(File.join(custom_dir, "application.#{extension}")) expanded_sources.delete('application') expanded_sources << "application" end @@ -106,8 +107,8 @@ module ActionView # # config.action_view.javascript_expansions[:defaults] = %w(foo.js bar.js) # - # When using <tt>:defaults</tt>, if an <tt>application.js</tt> file exists in - # <tt>public/javascripts</tt> it will be included as well at the end. + # When using <tt>:defaults</tt> or <tt>:all</tt>, if an <tt>application.js</tt> file exists + # in <tt>public/javascripts</tt> it will be included as well at the end. # # You can modify the HTML attributes of the script tag by passing a hash as the # last argument. @@ -133,14 +134,16 @@ module ActionView # # <script src="/javascripts/rails.js?1284139606"></script> # # <script src="/javascripts/application.js?1284139606"></script> # + # Note: The application.js file is only referenced if it exists + # # You can also include all JavaScripts in the +javascripts+ directory using <tt>:all</tt> as the source: # # javascript_include_tag :all # # => <script src="/javascripts/jquery.js?1284139606"></script> # # <script src="/javascripts/rails.js?1284139606"></script> - # # <script src="/javascripts/application.js?1284139606"></script> # # <script src="/javascripts/shop.js?1284139606"></script> # # <script src="/javascripts/checkout.js?1284139606"></script> + # # <script src="/javascripts/application.js?1284139606"></script> # # Note that your defaults of choice will be included first, so they will be available to all subsequently # included files. @@ -161,9 +164,9 @@ module ActionView # javascript_include_tag :all, :cache => true # # => <script src="/javascripts/jquery.js?1284139606"></script> # # <script src="/javascripts/rails.js?1284139606"></script> - # # <script src="/javascripts/application.js?1284139606"></script> # # <script src="/javascripts/shop.js?1284139606"></script> # # <script src="/javascripts/checkout.js?1284139606"></script> + # # <script src="/javascripts/application.js?1284139606"></script> # # # assuming config.perform_caching is true # javascript_include_tag :all, :cache => true |