Sha256: 7ea133312116ef930ee4417f918383fd29ffd4d2544ada55ea57797f27c6ff75
Contents?: true
Size: 1.48 KB
Versions: 5
Compression:
Stored size: 1.48 KB
Contents
module RailsConnector class WidgetRenderer < AbstractController::Base include Rails.application.routes.url_helpers include Rails.application.helpers include ActionController::Helpers include AbstractController::Rendering append_view_path File.join('app', 'widgets') append_view_path ActionController::Base.view_paths self.helpers_path = Rails.application.config.helpers_paths helper :all def initialize(request) @_request = request end def show(*args) render_action(:show, *args) end def edit(*args) render_action(:edit, *args) 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 exist. Please provide one.', view_context.image_tag('180x120.gif') ) end end def request @_request end def has_edit_view?(obj_class) lookup_context.find(action_view_path(:edit, obj_class)).present? rescue ActionView::MissingTemplate false end private def render_action(action_name, widget, obj, widget_field_name, container) @widget = widget @obj = obj @widget_field_name = widget_field_name @container = container render_to_string(action_view_path(action_name, widget.obj_class)) end def action_view_path(action_name, obj_class) "#{obj_class.underscore}/views/#{action_name}" end end end # module RailsConnector
Version data entries
5 entries across 5 versions & 1 rubygems