module RailsConnector class WidgetRenderer < AbstractController::Base include AbstractController::Rendering include AbstractController::Helpers helper :cms, "rails_connector/widget" self.view_paths = [File.join('app', 'widgets')] def initialize(request) @_request = request end def show(widget, obj, widget_field_name, container) @widget = widget @obj = obj @widget_field_name = widget_field_name @container = container render_to_string "#{widget.obj_class.underscore}/views/show" end def thumbnail(widget_dir) begin render_to_string "#{widget_dir}/views/thumbnail" rescue ActionView::MissingTemplate => e view_context.widget_thumbnail( widget_dir.titleize, 'thumbnail.html.erb does not existing. Please provide one.', view_context.image_tag('180x120.gif') ) end end def request @_request end end end # module RailsConnector