From 9de83050d3a4b260d4aeb5d09ec4eb64f913ba64 Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Mon, 15 Mar 2010 11:58:05 -0700 Subject: Add deprecation notices for <% %>. * The approach is to compile <% %> into a method call that checks whether the value returned from a block is a String. If it is, it concats to the buffer and prints a deprecation warning. * <%= %> uses exactly the same logic to compile the template, which first checks to see whether it's compiling a block. * This should have no impact on other uses of block in templates. For instance, in <% [1,2,3].each do |i| %><%= i %><% end %>, the call to each returns an Array, not a String, so the result is not concatenated * In two cases (#capture and #cache), a String can be returned that should *never* be concatenated. We have temporarily created a String subclass called NonConcattingString which behaves (and is serialized) identically to String, but is not concatenated by the code that handles deprecated <% %> block helpers. Once we remove support for <% %> block helpers, we can remove NonConcattingString. --- actionpack/lib/action_view/base.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'actionpack/lib/action_view/base.rb') diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index feaf45c333..3920d8593f 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -3,6 +3,9 @@ require 'active_support/core_ext/module/delegation' require 'active_support/core_ext/class/attribute' module ActionView #:nodoc: + class NonConcattingString < ActiveSupport::SafeBuffer + end + class ActionViewError < StandardError #:nodoc: end -- cgit v1.2.3 From 23b6def0eb76ac0719e420fce91ba862f880a37b Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Tue, 16 Mar 2010 14:55:42 -0700 Subject: Do not always include the named URL helpers into AC::Base and AV::Base. --- actionpack/lib/action_view/base.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'actionpack/lib/action_view/base.rb') diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 3920d8593f..daabe6d196 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -235,6 +235,10 @@ module ActionView #:nodoc: include controller._helpers self.helpers = controller._helpers end + + if controller.respond_to?(:_router) + include controller._router.url_helpers + end end else klass = self -- cgit v1.2.3 From a5587efc1903fd27d4b179753aa6e139445ad18c Mon Sep 17 00:00:00 2001 From: wycats Date: Wed, 17 Mar 2010 00:15:55 -0700 Subject: Remove some 1.9 warnings (resulting in some fixed bugs). Remaining AM warnings are in dependencies. --- actionpack/lib/action_view/base.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'actionpack/lib/action_view/base.rb') diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index daabe6d196..326b79f9bf 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -187,6 +187,7 @@ module ActionView #:nodoc: @@debug_rjs = false class_attribute :helpers + remove_method :helpers attr_reader :helpers class << self -- cgit v1.2.3 From d9375f3f302a5d1856ad57946c7263d4e6a45a2a Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Wed, 17 Mar 2010 16:28:05 -0700 Subject: Modify assert_template to use notifications. Also, remove ActionController::Base#template since it is no longer needed. --- actionpack/lib/action_view/base.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_view/base.rb') diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 326b79f9bf..4d9f53cf95 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -196,7 +196,7 @@ module ActionView #:nodoc: end attr_accessor :base_path, :assigns, :template_extension, :lookup_context - attr_internal :captures, :request, :layout, :controller, :template, :config + attr_internal :captures, :request, :controller, :template, :config delegate :find_template, :template_exists?, :formats, :formats=, :locale, :locale=, :view_paths, :view_paths=, :with_fallbacks, :update_details, :to => :lookup_context @@ -206,6 +206,11 @@ module ActionView #:nodoc: delegate :logger, :to => :controller, :allow_nil => true + # TODO: HACK FOR RJS + def view_context + self + end + def self.xss_safe? #:nodoc: true end @@ -254,7 +259,7 @@ module ActionView #:nodoc: @helpers = self.class.helpers || Module.new @_controller = controller - @_config = ActiveSupport::InheritableOptions.new(controller.config) if controller + @_config = ActiveSupport::InheritableOptions.new(controller.config) if controller && controller.respond_to?(:config) @_content_for = Hash.new { |h,k| h[k] = ActiveSupport::SafeBuffer.new } @_virtual_path = nil -- cgit v1.2.3 From 41af6d9a78446a5219a321cf638945b1608cefd8 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 17 Mar 2010 22:27:48 -0700 Subject: Use Array.wrap not Array() --- actionpack/lib/action_view/base.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'actionpack/lib/action_view/base.rb') diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 4d9f53cf95..859c5c0863 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -1,6 +1,7 @@ require 'active_support/core_ext/module/attr_internal' require 'active_support/core_ext/module/delegation' require 'active_support/core_ext/class/attribute' +require 'active_support/core_ext/array/wrap' module ActionView #:nodoc: class NonConcattingString < ActiveSupport::SafeBuffer @@ -216,7 +217,7 @@ module ActionView #:nodoc: end def self.process_view_paths(value) - ActionView::PathSet.new(Array(value)) + ActionView::PathSet.new(Array.wrap(value)) end def self.for_controller(controller) -- cgit v1.2.3 From 71c9337f45f9c5461cbc6ddf6cab764ad0f82c3b Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Thu, 18 Mar 2010 15:52:43 -0700 Subject: All tests pass without memoizing view_context --- actionpack/lib/action_view/base.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'actionpack/lib/action_view/base.rb') diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 859c5c0863..b82c6a8203 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -250,8 +250,6 @@ module ActionView #:nodoc: else klass = self end - - klass.new(controller.lookup_context, {}, controller) end def initialize(lookup_context = nil, assigns_for_first_render = {}, controller = nil, formats = nil) #:nodoc: -- cgit v1.2.3 From a5d80f84d269bba6b0f0802612f29df1ee09d720 Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Thu, 18 Mar 2010 18:12:04 -0700 Subject: Each controller class has it's own view context subclass. This removes the need for ActionView::Base.for_controller --- actionpack/lib/action_view/base.rb | 32 -------------------------------- 1 file changed, 32 deletions(-) (limited to 'actionpack/lib/action_view/base.rb') diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index b82c6a8203..66af693cde 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -220,38 +220,6 @@ module ActionView #:nodoc: ActionView::PathSet.new(Array.wrap(value)) end - def self.for_controller(controller) - @views ||= {} - - # TODO: Decouple this so helpers are a separate concern in AV just like - # they are in AC. - if controller.class.respond_to?(:_helper_serial) - klass = @views[controller.class._helper_serial] ||= Class.new(self) do - # Try to make stack traces clearer - class_eval <<-ruby_eval, __FILE__, __LINE__ + 1 - def self.name - "ActionView for #{controller.class}" - end - - def inspect - "#<#{self.class.name}>" - end - ruby_eval - - if controller.respond_to?(:_helpers) - include controller._helpers - self.helpers = controller._helpers - end - - if controller.respond_to?(:_router) - include controller._router.url_helpers - end - end - else - klass = self - end - end - def initialize(lookup_context = nil, assigns_for_first_render = {}, controller = nil, formats = nil) #:nodoc: @config = nil @assigns = assigns_for_first_render.each { |key, value| instance_variable_set("@#{key}", value) } -- cgit v1.2.3 From 9f92563892007c7f42a51ec7926352d50d596579 Mon Sep 17 00:00:00 2001 From: wycats Date: Fri, 19 Mar 2010 11:49:53 -0700 Subject: Eliminate an error from an implicit dependency on AV::Base --- actionpack/lib/action_view/base.rb | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'actionpack/lib/action_view/base.rb') diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 66af693cde..9eec8ecce8 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -7,27 +7,6 @@ module ActionView #:nodoc: class NonConcattingString < ActiveSupport::SafeBuffer end - class ActionViewError < StandardError #:nodoc: - end - - class MissingTemplate < ActionViewError #:nodoc: - attr_reader :path - - def initialize(paths, path, details, partial) - @path = path - display_paths = paths.compact.map{ |p| p.to_s.inspect }.join(", ") - template_type = if partial - "partial" - elsif path =~ /layouts/i - 'layout' - else - 'template' - end - - super("Missing #{template_type} #{path} with #{details.inspect} in view paths #{display_paths}") - end - end - # Action View templates can be written in three ways. If the template file has a .erb (or .rhtml) extension then it uses a mixture of ERb # (included in Ruby) and HTML. If the template file has a .builder (or .rxml) extension then Jim Weirich's Builder::XmlMarkup library is used. # If the template file has a .rjs extension then it will use ActionView::Helpers::PrototypeHelper::JavaScriptGenerator. -- cgit v1.2.3 From 395d6648ce7549f71dd0a76dc061e87f608aaaab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 26 Mar 2010 18:47:55 +0100 Subject: Move application configuration to the application configuration object, remove railtie_name and engine_name and allow to set the configuration object. --- actionpack/lib/action_view/base.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_view/base.rb') diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 9eec8ecce8..919b1e3470 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -159,8 +159,6 @@ module ActionView #:nodoc: include Helpers, Rendering, Partials, Layouts, ::ERB::Util, Context extend ActiveSupport::Memoizable - ActionView.run_base_hooks(self) - # Specify whether RJS responses should be wrapped in a try/catch block # that alert()s the caught exception (and then re-raises it). cattr_accessor :debug_rjs @@ -175,6 +173,8 @@ module ActionView #:nodoc: delegate :logger, :to => 'ActionController::Base', :allow_nil => true end + ActionView.run_base_hooks(self) + attr_accessor :base_path, :assigns, :template_extension, :lookup_context attr_internal :captures, :request, :controller, :template, :config -- cgit v1.2.3