lib/cells/cell/base.rb in cells-3.3.1 vs lib/cells/cell/base.rb in cells-3.3.2
- old
+ new
@@ -321,23 +321,34 @@
# ==== 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={})
- render_view_for(opts, @state_name) ### FIXME: i don't like the magic access to @state_name here. ugly!
+ def render(opts={}, &block)
+ render_view_for(opts, @state_name, &block)
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)
+ def render_view_for(opts, state, &block)
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])
@@ -451,11 +462,10 @@
# View instance.
def ivars_to_ignore; ['@controller']; end
### TODO: allow log levels.
def log(message)
- return unless @controller.logger
- @controller.logger.debug(message)
+ @controller.logger and @controller.logger.debug(message)
end
end
end
end