Sha256: 4a9a2ba99f0b639f4a4b748e05de2b95de6c38c97ae5b0b8ae01dbbe9ca3449d

Contents?: true

Size: 897 Bytes

Versions: 1

Compression:

Stored size: 897 Bytes

Contents

# frozen_string_literal: true

module Occams::Seeds::Snippet
  class Exporter < Occams::Seeds::Exporter

    def initialize(from, to = from)
      super
      self.path = ::File.join(Occams.config.seeds_path, to, "snippets/")
    end

    def export!
      prepare_folder!(path)

      site.snippets.each do |snippet|
        attrs = {
          "label"       => snippet.label,
          "categories"  => snippet.categories.map(&:label),
          "position"    => snippet.position
        }.to_yaml

        data = []
        data << { header: "attributes", content: attrs }
        data << { header: "content", content: snippet.content }

        snippet_path = File.join(path, "#{snippet.identifier}.html")
        write_file_content(snippet_path, data)

        message = "[CMS SEEDS] Exported Snippet \t #{snippet.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/snippet/exporter.rb