class ComfortableMexicanSofa::Seeds::Layout::Exporter

Public Class Methods

new(from, to = from) click to toggle source
# File lib/comfortable_mexican_sofa/seeds/layout/exporter.rb, line 6
def initialize(from, to = from)
  super
  self.path = ::File.join(ComfortableMexicanSofa.config.seeds_path, to, "layouts/")
end

Public Instance Methods

export!() click to toggle source
# File lib/comfortable_mexican_sofa/seeds/layout/exporter.rb, line 11
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}"
    ComfortableMexicanSofa.logger.info(message)
  end
end