lib/cells/cell/base.rb in cells-3.3.2 vs lib/cells/cell/base.rb in cells-3.3.3

- old
+ new

@@ -138,10 +138,11 @@ # # If gettext is set to DE_de, the latter view will be chosen. class Base include ::ActionController::Helpers include ::ActionController::RequestForgeryProtection + include ActiveHelper class_inheritable_array :view_paths, :instance_writer => false write_inheritable_attribute(:view_paths, ActionView::PathSet.new) # Force use of a PathSet in this attribute, self.view_paths = ActionView::PathSet.new would still yield in an array class << self @@ -321,34 +322,23 @@ # ==== Where have all the partials gone? # In Cells we abandoned the term 'partial' in favor of plain 'views' - we don't need to distinguish # between both terms. A cell view is both, a view and a kind of partial as it represents only a small # part of the page. # Just use <tt>:view</tt> and enjoy. - def render(opts={}, &block) - render_view_for(opts, @state_name, &block) + def render(opts={}) + render_view_for(opts, @state_name) ### FIXME: i don't like the magic access to @state_name here. ugly! end # Render the view belonging to the given state. Will raise ActionView::MissingTemplate # if it can not find one of the requested view template. Note that this behaviour was # introduced in cells 2.3 and replaces the former warning message. - def render_view_for(opts, state, &block) + def render_view_for(opts, state) return '' if opts[:nothing] action_view = setup_action_view ### TODO: dispatch dynamically: - if opts[:erector] - require 'erector' - #puts self.class.master_helper_module.instance_methods - #extend self.class.master_helper_module - #return Erector.inline(assigns_for_view, &block).to_s(:helpers => action_view, :parent => action_view) - #include_helpers_in_class(action_view.class) - action_view.output_buffer="" - return Erector.inline(assigns_for_view, &block).to_s(:parent => action_view) - end - - if opts[:text] elsif opts[:inline] elsif opts[:file] elsif opts[:state] opts[:text] = render_state(opts[:state]) @@ -376,10 +366,12 @@ end def prepare_action_view_for(action_view, opts) # make helpers available: include_helpers_in_class(action_view.class) + + import_active_helpers_into(action_view) # in Cells::Cell::ActiveHelper. action_view.assigns = assigns_for_view # make instance vars available. action_view.template_format = opts[:template_format] end @@ -462,10 +454,11 @@ # View instance. def ivars_to_ignore; ['@controller']; end ### TODO: allow log levels. def log(message) - @controller.logger and @controller.logger.debug(message) + return unless @controller.logger + @controller.logger.debug(message) end end end end