Sha256: 32676ff3d3ca47e37b7203f8c3754b1fd0af4b338b959b43917f9c5c9d8e8c30

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

class BootstrapGenerator < Rails::Generators::Base
  source_root File.expand_path("../templates", __FILE__)
  argument :resource_name, type: :string, default: "application"
  class_option :haml, type: :boolean, default: false, description: "Generate haml templates"

  def add_gems
    gem "bootstrap-sass"
  end

  def create_scss_files
    copy_file "_variables.css.scss", "app/assets/stylesheets/#{resource_name}/_variables.css.scss"
    copy_file "_application.css.scss", "app/assets/stylesheets/#{resource_name}/_#{resource_name}.css.scss"
  end

  def create_scss_manifest
    template "application.scss", "app/assets/stylesheets/#{resource_name}.scss"
  end

  def create_coffee_manifest
    template "application.js", "app/assets/javascripts/#{resource_name}.js"
  end

  def create_layout
    if options[:haml]
      template "application.html.haml", "app/views/layouts/#{resource_name}.html.haml"
    else
      template "application.html.erb", "app/views/layouts/#{resource_name}.html.erb"
    end
  end

  private

  def application_name
    Rails.application.class.name.split("::").first
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mac_generators-0.3.1 lib/generators/bootstrap/bootstrap_generator.rb