Sha256: f80d9041dec3fd91d4bf5ee7eb9787f4788b860d99fbaabb9705809f15add7f2
Contents?: true
Size: 1.23 KB
Versions: 6
Compression:
Stored size: 1.23 KB
Contents
# frozen_string_literal: true module Maglev class PageComponent < BaseComponent attr_reader :site, :theme, :page, :page_sections, :templates_root_path, :config, :rendering_mode # rubocop:disable Lint/MissingSuper def initialize(site:, theme:, page:, page_sections:, context:) @site = site @theme = theme @page = page @page_sections = page_sections @templates_root_path = context[:templates_root_path] @config = context[:config] @rendering_mode = context[:rendering_mode] end # rubocop:enable Lint/MissingSuper # Sections within a dropzone def sections @sections ||= page_sections.map do |attributes| definition = theme.sections.find(attributes['type']) next unless definition build_section(definition, attributes) end.compact end def render sections.collect(&:render).join end private def build_section(definition, attributes) build( SectionComponent, parent: self, definition: definition, attributes: attributes.deep_transform_keys! { |k| k.to_s.underscore.to_sym }, templates_root_path: templates_root_path, rendering_mode: rendering_mode ) end end end
Version data entries
6 entries across 6 versions & 1 rubygems