Sha256: 990faa728b9ce07c13279491242d7efe6efcdfb9f927261e20495d4a1f1f58c6

Contents?: true

Size: 885 Bytes

Versions: 1

Compression:

Stored size: 885 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.1 lib/occams/seeds/snippet/exporter.rb