Sha256: 93b7fa7e7138503b9da0b5a3feb942a07e287717314850c643caefca96acb689

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

# Provides specific helper methods to render content blocks and connectors.
# Split off from Cms::ApplicationController so it can be included in Cms::Acts::ContentPage
module Cms
  module RenderingHelper
    def render_connector_and_connectable(connector, connectable)
      if logged_in? && @mode == "edit" && current_user.able_to_edit?(connector.page)
        render :partial => 'cms/pages/edit_connector',
               :locals => { :connector => connector, :connectable => connectable}
      else
        render_connectable(connectable)
      end
    end

    def render_connectable(content_block)
      if content_block
        if content_block.class.renderable?
          logger.info "..... Rendering connectable #{content_block.class} ##{content_block.id} #{"v#{content_block.version}" if content_block.respond_to?(:version)}"
          content_block.perform_render(@controller)
        else
          logger.warn "Connectable #{content_block.class} ##{content_block.id} is not renderable"
        end
      else
        logger.warn "Connectable is null"
      end
    rescue Exception => e
      logger.error "Error occurred while rendering #{content_block.class}##{content_block.id}: #{e.message}\n#{e.backtrace.join("\n")}"
      "ERROR: #{e.message}"
    end

    # Helper that will render the toolbar for the CMS.
    # Expects:
    #   tab - Symbol for which tab of the dashboard to highlight. Defaults to :dashboard.
    #
    def render_cms_toolbar(tab=:dashboard)
      render :partial => 'layouts/cms_toolbar', :locals => {:tab => tab}
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bf4-browsercms-3.1.0 app/helpers/cms/rendering_helper.rb