Sha256: 499bfb164e89a4209ea65a52964f9c63f60b34de38714147232df1ec617dbf9f

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require 'rails/generators'

module TemplatorChabz
  module Generators
    class TemplateGenerator < Rails::Generators::Base
      ZB_TEMPLATES = ['banded','blog', 'feed', 'grid', 'orbit', 'banner-home', 'sidebar']

      class_option :haml, type: :boolean, desc: "Generate HAML layout"
      class_option :framework, type: :string, default: "foundation"
      class_option :template, type: :string, default: "blog"

      def self.source_root
        @source_root ||= File.join(File.dirname(__FILE__), 'templates')
      end

      def create_template
        if ZB_TEMPLATES.include?(options.template) && options.framework == "foundation"
          if options.haml?
            remove_file "app/views/layouts/application.html.erb"
            template "foundation/haml/#{options.template}.html.haml", "app/views/layouts/application.html.haml"
          else
            remove_file "app/views/layouts/application.html.haml"
            template "foundation/erb/#{options.template}.html.erb", "app/views/layouts/application.html.erb"
          end
        else
          raise "template not found."
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
templator_chabz-0.9.0 lib/generators/templator_chabz/template_generator.rb