Sha256: 9ac3b97fdbcb9a0351eaa62b1c90ebcf1fbd5b6560e52d86af564c19e567ccd3

Contents?: true

Size: 1.68 KB

Versions: 6

Compression:

Stored size: 1.68 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)
      logger.warn "Rendering #{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.debug "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

    ##
    # Renders the toolbar for the CMS. All page templates need to include this or they won't be editable.
    # Typically rendered as an iframe to avoid CSS/JS conflicts.
    #
    # @param [Symbol] tab 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

6 entries across 6 versions & 1 rubygems

Version Path
browsercms-3.4.2 app/helpers/cms/rendering_helper.rb
browsercms-3.4.2.rc1 app/helpers/cms/rendering_helper.rb
browsercms-3.4.1 app/helpers/cms/rendering_helper.rb
browsercms-3.4.0 app/helpers/cms/rendering_helper.rb
browsercms-3.4.0.rc2 app/helpers/cms/rendering_helper.rb
browsercms-3.4.0.rc1 app/helpers/cms/rendering_helper.rb