Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Performance: Cache modules that extend the view context for JavaScrip…

…tGenerator
  • Loading branch information...
commit f2d8d13c6495f2a9b3bbf3b50d869c0e5b25c207 1 parent ba0d621
Joshua Peek josh authored
8 actionpack/lib/action_view/base.rb
View
@@ -158,6 +158,7 @@ def initialize(paths, path, template_format = nil)
# See the ActionView::Helpers::PrototypeHelper::GeneratorMethods documentation for more details.
class Base
include ERB::Util
+ extend ActiveSupport::Memoizable
attr_accessor :base_path, :assigns, :template_extension
attr_accessor :controller
@@ -324,11 +325,14 @@ def pick_template(template_path)
template
end
end
-
- extend ActiveSupport::Memoizable
memoize :pick_template
private
+ def extended_by_without_helpers #:nodoc:
+ extended_by.reject { |mod| mod.name =~ /^ActionView::Helpers/ }
+ end
+ memoize :extended_by_without_helpers
+
# Evaluate the local assigns and pushes them to the view.
def evaluate_assigns
unless @assigns_added
4 actionpack/lib/action_view/helpers/prototype_helper.rb
View
@@ -588,9 +588,7 @@ def initialize(context, &block) #:nodoc:
private
def include_helpers_from_context
- @context.extended_by.each do |mod|
- extend mod unless mod.name =~ /^ActionView::Helpers/
- end
+ @context.send(:extended_by_without_helpers).each { |mod| extend mod }
extend GeneratorMethods
end
5 actionpack/test/template/javascript_helper_test.rb
View
@@ -108,4 +108,9 @@ def test_javascript_tag_with_block_and_options_in_erb
def test_javascript_cdata_section
assert_dom_equal "\n//<![CDATA[\nalert('hello')\n//]]>\n", javascript_cdata_section("alert('hello')")
end
+
+ private
+ def extended_by_without_helpers
+ []
+ end
end
4 actionpack/test/template/prototype_helper_test.rb
View
@@ -53,6 +53,10 @@ def protect_against_forgery?
false
end
+ def extended_by_without_helpers
+ []
+ end
+
def create_generator
block = Proc.new { |*args| yield *args if block_given? }
JavaScriptGenerator.new self, &block
Please sign in to comment.
Something went wrong with that request. Please try again.