Sha256: 7ac08186295a9270d3575097893abd12258cfb6383933c8ef24c9c07b684158f
Contents?: true
Size: 1.51 KB
Versions: 65
Compression:
Stored size: 1.51 KB
Contents
module Scrivito class WidgetTag < BaseWidgetTag def render super rescue => error if handle_render_errors? errored_widget_tag(error).render else raise error end end def content render_content(render_context) end def html_options @html_options || super end private def errored_widget_tag(error) ErroredWidgetTag.new(view, widget, placement_modification: placement_modification, render_context: render_context, inner_tag: inner_tag, error: error) end def description_for_editor widget.description_for_editor end def render_content(context) template_path = widget.public_send("#{context}_view_path") view.render(template: template_path, locals: {widget: widget}).tap do @html_options = view.instance_variable_get(:@scrivito_widget_tag_html_options) view.instance_variable_set(:@scrivito_widget_tag_html_options, nil) end rescue ActionView::MissingTemplate if context == DEFAULT_RENDER_CONTEXT if view.scrivito_user view.content_tag(:h4, "Error: Missing 'show' template for #{widget.obj_class}", class: 'scrivito_error') end else render_content(DEFAULT_RENDER_CONTEXT) end end def render_context super || DEFAULT_RENDER_CONTEXT end def has_widget_details_view?(widget) view.lookup_context.find(widget.details_view_path).present? rescue ActionView::MissingTemplate false end def handle_render_errors? !Rails.env.development? && !Rails.env.test? end end end
Version data entries
65 entries across 65 versions & 1 rubygems