Sha256: bdbfdd15e9e40d686807ba9d2d5b8737b62c9f7d84c7112d0e00700b2ba684ec

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require 'pathname'
require "generators/kiso_themes/handler_support"
require_relative "../../../support/page_rewriter"

module KisoThemes
  module Generators
    class ContentBlocksGenerator < Rails::Generators::Base
      include HandlerSupport

      desc "Copies the bundled content blocks into your views directory."
      source_root File.expand_path('../../../../app/views', __FILE__)
      namespace "kiso_themes:content_blocks"

      def copy_content_blocks
        layouts_path = "app/views/content_blocks"
        source_path = "../../../../app/views/content_blocks"
        target_full_base_path = Pathname.new(File.expand_path(source_path, __FILE__))
        layouts = Dir.glob(File.expand_path("#{source_path}/**/*", __FILE__)).select { |lf|
          lf.end_with? handler
        }.map { |lf|
          Pathname.new(lf).relative_path_from(target_full_base_path).to_s
        }

        layouts.each do |name|
          copy_file File.join(source_path, name), "#{layouts_path}/#{name}"
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kiso_themes-1.0.2 lib/generators/kiso_themes/content_blocks_generator.rb