Module: Cmsimple::RegionsHelper

Defined in:
app/helpers/cmsimple/regions_helper.rb

Instance Method Summary collapse

Instance Method Details

#region_content(region) ⇒ Object



8
9
10
11
12
13
# File 'app/helpers/cmsimple/regions_helper.rb', line 8

def region_content(region)
  region.render_snippets do |snippet|
    render_snippet(snippet)
  end
  raw region
end

#render_region(region_name, options = {}, &block) ⇒ Object



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

def render_region(region_name, options={}, &block)
  content = region_content(resource_regions.send(region_name))

  if content.blank? && block_given?
    content = capture(&block)
  end

  if options[:tag]
    html_options = options[:html].presence || {}
    html_options = html_options.merge(:id => region_name, :'data-mercury' => options[:region_type] || 'full')

    content =  options[:tag], content, html_options
  end

  raw content
end

#render_snippet(snippet) ⇒ Object



32
33
34
35
# File 'app/helpers/cmsimple/regions_helper.rb', line 32

def render_snippet(snippet)
  return '' unless snippet.name.present?
  render_cell snippet.name, :display, snippet
end

#resource_regionsObject



4
5
6
# File 'app/helpers/cmsimple/regions_helper.rb', line 4

def resource_regions
  @page.regions
end