Sha256: 6fbbf60acaa7bad503b09a564cef62e3513e39290a2d34c6cb6a581156d4bf3a

Contents?: true

Size: 1.16 KB

Versions: 28

Compression:

Stored size: 1.16 KB

Contents

class NiftyLayoutGenerator < Rails::Generator::Base
  def initialize(runtime_args, runtime_options = {})
    super
    @name = @args.first || 'application'
  end
  
  def manifest
    record do |m|
      m.directory 'app/views/layouts'
      m.directory 'public/stylesheets'
      m.directory 'app/helpers'
      
      if options[:haml]
        m.directory 'public/stylesheets/sass'
        m.template "layout.html.haml", "app/views/layouts/#{file_name}.html.haml"
        m.file     "stylesheet.sass",  "public/stylesheets/sass/#{file_name}.sass"
      else
        m.template "layout.html.erb", "app/views/layouts/#{file_name}.html.erb"
        m.file     "stylesheet.css",  "public/stylesheets/#{file_name}.css"
      end
      m.file "helper.rb", "app/helpers/layout_helper.rb"
    end
  end
  
  def file_name
    @name.underscore
  end

  protected

    def add_options!(opt)
      opt.separator ''
      opt.separator 'Options:'
      opt.on("--haml", "Generate HAML for view, and SASS for stylesheet.") { |v| options[:haml] = v }
    end

    def banner
      <<-EOS
Creates generic layout, stylesheet, and helper files.

USAGE: #{$0} #{spec.name} [layout_name]
EOS
    end
end

Version data entries

28 entries across 28 versions & 13 rubygems

Version Path
intinno-nifty-generators-0.2.5 rails_generators/nifty_layout/nifty_layout_generator.rb
polly-nifty-generators-0.2.3 rails_generators/nifty_layout/nifty_layout_generator.rb
rubycs-nifty-generators-compass-0.0.1 rails_generators/nifty_layout/nifty_layout_generator.rb
ryanb-nifty-generators-0.1.5 rails_generators/nifty_layout/nifty_layout_generator.rb
ryanb-nifty-generators-0.1.6 rails_generators/nifty_layout/nifty_layout_generator.rb
ryanb-nifty-generators-0.1.7 rails_generators/nifty_layout/nifty_layout_generator.rb
twilson63-nifty-generators-0.2.5 rails_generators/nifty_layout/nifty_layout_generator.rb
twilson63-nifty-generators-0.2.6 rails_generators/nifty_layout/nifty_layout_generator.rb
unittk-nifty-generators-0.1.7.1 rails_generators/nifty_layout/nifty_layout_generator.rb
unittk-nifty-generators-0.1.7.2 rails_generators/nifty_layout/nifty_layout_generator.rb
unittk-nifty-generators-0.1.7 rails_generators/nifty_layout/nifty_layout_generator.rb
corntrace-nifty-generators-0.4.1 rails_generators/nifty_layout/nifty_layout_generator.rb
corntrace-nifty-generators-0.4.0 rails_generators/nifty_layout/nifty_layout_generator.rb
nifty-generators-0.4.0 rails_generators/nifty_layout/nifty_layout_generator.rb
nifty-generators-0.3.2 rails_generators/nifty_layout/nifty_layout_generator.rb
linki-nifty-generators-0.3.1 rails_generators/nifty_layout/nifty_layout_generator.rb
linki-nifty_generators-0.3.1 rails_generators/nifty_layout/nifty_layout_generator.rb
minerva-nifty-generators-0.3.0 rails_generators/nifty_layout/nifty_layout_generator.rb
xenda-nifty-generators-0.3.2 rails_generators/nifty_layout/nifty_layout_generator.rb
nifty-generators-0.3.0 rails_generators/nifty_layout/nifty_layout_generator.rb