Sha256: e7c294642b261a8cb91b547d57a3b7fb74ea71f1e9352da7c8defc51cb7a59fc
Contents?: true
Size: 1.18 KB
Versions: 18
Compression:
Stored size: 1.18 KB
Contents
# frozen_string_literal: true module Maglev class PageComponent < BaseComponent attr_reader :site, :theme, :page, :page_sections, :templates_root_path, :config # rubocop:disable Lint/MissingSuper, Metrics/ParameterLists def initialize(site:, theme:, page:, page_sections:, templates_root_path:, config:) @site = site @theme = theme @page = page @page_sections = page_sections @templates_root_path = templates_root_path @config = config end # rubocop:enable Lint/MissingSuper, Metrics/ParameterLists # 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 ) end end end
Version data entries
18 entries across 18 versions & 1 rubygems