aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb
diff options
context:
space:
mode:
authorJosh Kalderimis <josh.kalderimis@gmail.com>2010-11-15 16:57:20 +0100
committerJosé Valim <jose.valim@gmail.com>2010-11-16 00:04:37 +0100
commit6a609dbc82d03eb92a85970aa157192657f14882 (patch)
tree555a8029cef31d2c5172c17df14512c699de6af7 /actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb
parent6747ae2708d2ad8a482f3dfcb346d007a51af77a (diff)
downloadrails-6a609dbc82d03eb92a85970aa157192657f14882.tar.gz
rails-6a609dbc82d03eb92a85970aa157192657f14882.tar.bz2
rails-6a609dbc82d03eb92a85970aa157192657f14882.zip
incorporated most of the feedback from José
Diffstat (limited to 'actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb')
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb24
1 files changed, 13 insertions, 11 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 de581a2737..72615220fa 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
@@ -11,8 +11,13 @@ module ActionView
class JavascriptIncludeTag < AssetIncludeTag
include TagHelper
- self.asset_name = 'javascript'
- self.extension = 'js'
+ def asset_name
+ 'javascript'
+ end
+
+ def extension
+ 'js'
+ end
def asset_tag(source, options)
content_tag("script", "", { "type" => Mime::JS, "src" => path_to_asset(source) }.merge(options))
@@ -40,14 +45,8 @@ module ActionView
module JavascriptTagHelpers
extend ActiveSupport::Concern
- extend HelperMacros
include CommonAssetHelpers
- included do
- mattr_accessor :javascript_expansions
- self.javascript_expansions = { }
- end
-
module ClassMethods
# Register one or more javascript files to be included when <tt>symbol</tt>
# is passed to <tt>javascript_include_tag</tt>. This method is typically intended
@@ -61,7 +60,7 @@ module ActionView
# <script type="text/javascript" src="/javascripts/body.js"></script>
# <script type="text/javascript" src="/javascripts/tail.js"></script>
def register_javascript_expansion(expansions)
- self.javascript_expansions.merge!(expansions)
+ JavascriptIncludeTag.expansions.merge!(expansions)
end
end
@@ -76,7 +75,10 @@ module ActionView
# javascript_path "/dir/xmlhr" # => /dir/xmlhr.js
# 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
- asset_path :javascript, 'js'
+ def javascript_path(source)
+ compute_public_path(source, 'javascripts', 'js')
+ end
+ alias_method :path_to_javascript, :javascript_path # aliased to avoid conflicts with a javascript_path named route
# Returns an HTML script tag for each of the +sources+ provided. You
# can pass in the filename (.js extension is optional) of JavaScript files
@@ -161,7 +163,7 @@ module ActionView
#
# javascript_include_tag :all, :cache => true, :recursive => true
def javascript_include_tag(*sources)
- @javascript_include ||= JavascriptIncludeTag.new(config, controller, self.javascript_expansions)
+ @javascript_include ||= JavascriptIncludeTag.new(config, controller)
@javascript_include.include_tag(*sources)
end