Sha256: 6fb5888de9e39c0f1992099a61d36a0e2d3407e83e81b9a6ff1e11b9baf22db3

Contents?: true

Size: 1.23 KB

Versions: 6

Compression:

Stored size: 1.23 KB

Contents

require 'generators/sht_rails/helpers'
require 'rails'

module ShtRails
  module Generators
    class InstallGenerator < Rails::Generators::Base
      include ShtRails::Generators::Helpers

      desc "Install into rails"
      
      class_option :manifest, :type => :string, :aliases => "-m", :default => 'application.js',
                                      :desc => "Javascript manifest file to modify (or create)"
                                      
      class_option :template_dir, :type => :string, :aliases => "-t", :default => 'templates',
                                      :desc => "Template dir for mustache templates"

      def inject_mustache
        manifest = options[:manifest]
        template_dir = options[:template_dir]

        create_file("#{js_path}/#{manifest}") unless File.exists?("#{js_path}/#{manifest}")

        append_to_file "#{js_path}/#{manifest}" do
          out = ""
          out << "//= require handlebars"
          out << "\n"
          out << "//= require_tree ../../#{template_dir}"
          out << "\n"
          out << "\n"
        end
      end
      
      def create_dir
        template_dir = options[:template_dir]
        empty_directory "#{app_path}/#{template_dir}"
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sht_rails-0.2.3 lib/generators/sht_rails/install/install_generator.rb
sht_rails-0.2.2 lib/generators/sht_rails/install/install_generator.rb
sht_rails-0.2.1 lib/generators/sht_rails/install/install_generator.rb
sht_rails-0.2.0 lib/generators/sht_rails/install/install_generator.rb
sht_rails-0.1.1 lib/generators/sht_rails/install/install_generator.rb
sht_rails-0.1.0 lib/generators/sht_rails/install/install_generator.rb