Module: Skyline::Rendering::Helpers::ColumnHelper

Included in:
Renderer::Helpers
Defined in:
lib/skyline/rendering/helpers/column_helper.rb

Instance Method Summary collapse

Instance Method Details

#sections_per_column(page_version) ⇒ Array<Array<Section>> Also known as: page_sections_per_column

Devides the sections into columns depending on splitter location

Parameters:

  • page_version (ArticleVersion)

    The ArticleVersion to get section from to split

Returns:

  • (Array<Array<Section>>)

    An array of columns each containing and array of sections.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/skyline/rendering/helpers/column_helper.rb', line 8

def sections_per_column(page_version)
  sections_per_col ||= []
  col = 0
  page_version.sections.each do |section|
    if section.sectionable_type == "Skyline::Sections::SplitterSection" 
      col += 1
    else
      sections_per_col[col] ||= []
      sections_per_col[col].push(section)
    end
  end
  sections_per_col
end