Sha256: e9ca1ca865ec0c1ebd9eeaafb2287449a797e9fe9f318dd47bbf60a4bb32e641

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

module Occams::Seeds::Layout
  class Exporter < Occams::Seeds::Exporter

    def initialize(from, to = from)
      super
      self.path = ::File.join(Occams.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}"
        Occams.logger.info(message)
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
occams-1.0.0 lib/occams/seeds/layout/exporter.rb