Module: Cms::RenderingHelper

Defined in:
app/helpers/cms/rendering_helper.rb

Instance Method Summary collapse

Instance Method Details

#render_cms_toolbar(tab = :dashboard) ⇒ Object

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.

Parameters:

  • tab (Symbol) (defaults to: :dashboard)

    Which tab of the dashboard to highlight. Defaults to :dashboard.



38
39
40
# File 'app/helpers/cms/rendering_helper.rb', line 38

def render_cms_toolbar(tab=:dashboard)
  render :partial => 'layouts/cms_toolbar', :locals => {:tab => tab}
end

#render_connectable(content_block) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/helpers/cms/rendering_helper.rb', line 16

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

#render_connector_and_connectable(connector, connectable) ⇒ Object



7
8
9
10
11
12
13
14
# File 'app/helpers/cms/rendering_helper.rb', line 7

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