Sha256: f44d5b8a4e8c1df1f3e0bfe1febf47203a643cd02f77d964c314dc7e39f9c0cb

Contents?: true

Size: 1.59 KB

Versions: 3

Compression:

Stored size: 1.59 KB

Contents

require 'rails/generators'

module Bootstrap
  module Generators
    class InstallGenerator < ::Rails::Generators::Base
      desc 'Copy BootstrapGenerators default files'
      source_root File.expand_path('../templates', __FILE__)

      class_option :template_engine
      class_option :stylesheet_engine

      def copy_lib
        directory "lib/templates/#{options[:template_engine]}"
      end

      def copy_form_builder
        copy_file "form_builders/form_builder/_form.html.#{options[:template_engine]}", "lib/templates/#{options[:template_engine]}/scaffold/_form.html.#{options[:template_engine]}"
      end

      def create_layout
        template "layouts/starter.html.#{options[:template_engine]}", "app/views/layouts/application.html.#{options[:template_engine]}"
      end

      def create_stylesheets
        stylesheet_extension = options[:stylesheet_engine] || 'css'

        copy_file "assets/stylesheets/starter.#{stylesheet_extension}", "app/assets/stylesheets/bootstrap-generators.#{stylesheet_extension}"

        if [:less, :scss].include?(options[:stylesheet_engine].to_sym)
          copy_file "assets/stylesheets/bootstrap-variables.#{stylesheet_extension}", "app/assets/stylesheets/bootstrap-variables.#{stylesheet_extension}"
        end
      end

      def inject_backbone
        application_js_path = "app/assets/javascripts/application.js"

        if File.exists?(File.join(destination_root, application_js_path))
          inject_into_file application_js_path, :before => "//= require_tree" do
            "//= require bootstrap\n"
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bootstrap-generators-3.0.2 lib/generators/bootstrap/install/install_generator.rb
bootstrap-generators-3.0.0.1 lib/generators/bootstrap/install/install_generator.rb
bootstrap-generators-3.0.0 lib/generators/bootstrap/install/install_generator.rb