Sha256: fceb66248dc2cf84fa488910fee2a26a19a560b2f11bb39d2e1e9e4dc0e238c5

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

module ComfortableMediaSurfer::Seeds::Layout
  class Exporter < ComfortableMediaSurfer::Seeds::Exporter
    def initialize(from, to = from)
      super
      self.path = ::File.join(ComfortableMediaSurfer.config.seeds_path, to, 'layouts/')
    end

    def export!
      prepare_folder!(path)

      site.layouts.each do |layout|
        layout_path = File.join(path, layout.ancestors.reverse.collect(&:identifier), layout.identifier)
        FileUtils.mkdir_p(layout_path)

        path = ::File.join(layout_path, 'content.html')
        data = []

        attrs = {
          'label' => layout.label,
          'app_layout' => layout.app_layout,
          'position' => layout.position
        }.to_yaml

        data << { header: 'attributes',  content: attrs }
        data << { header: 'content',     content: layout.content }
        data << { header: 'js',          content: layout.js }
        data << { header: 'css',         content: layout.css }

        write_file_content(path, data)

        message = "[CMS SEEDS] Exported Layout \t #{layout.identifier}"
        ComfortableMediaSurfer.logger.info(message)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
comfortable_media_surfer-3.0.0 lib/comfortable_media_surfer/seeds/layout/exporter.rb