Sha256: 3876b0776975606fb5059d418c0c00dc594aa78ea9b6b8eb978704b348e0e09a

Contents?: true

Size: 1.25 KB

Versions: 22

Compression:

Stored size: 1.25 KB

Contents

require 'generators/mustache'
require 'rails/generators/named_base'

class Mustache
  module Generators
    class ControllerGenerator < ::Rails::Generators::NamedBase
      extend TemplatePath
      
      argument :actions, :type => :array, :default => [], :banner => "action action"

      def create_view_files
        model_path                  = File.join(class_path, file_name)
        
        base_mustache_view_path     = File.join("app/views", model_path)
        empty_directory base_mustache_view_path
        
        base_mustache_template_path = File.join("app/templates", model_path)
        empty_directory base_mustache_template_path
        
        actions.each do |action|
          @action  = action
          mustache_view_path       = File.join(base_mustache_view_path,
                                                "#{action}.rb")
          mustache_template_path   = File.join(base_mustache_template_path,
                                                "#{action}.html.mustache")
          
          template "view.rb.erb", mustache_view_path
          template "view.html.mustache.erb", mustache_template_path                                   
        end
      end
      
      protected

      def handler
        :haml
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
rails3-generators-1.0.0 lib/generators/mustache/controller/controller_generator.rb
rails3-generators-0.17.6 lib/generators/mustache/controller/controller_generator.rb
rails3-generators-0.17.5 lib/generators/mustache/controller/controller_generator.rb
rails3-generators-0.17.4 lib/generators/mustache/controller/controller_generator.rb
rails3-generators-0.17.3 lib/generators/mustache/controller/controller_generator.rb
rails3-generators-0.17.2 lib/generators/mustache/controller/controller_generator.rb
rails3-generators-0.17.1 lib/generators/mustache/controller/controller_generator.rb
rails3-generators-0.17.0 lib/generators/mustache/controller/controller_generator.rb
rails3-generators-0.16.1 lib/generators/mustache/controller/controller_generator.rb
rails3-generators-0.16.0 lib/generators/mustache/controller/controller_generator.rb
rails3-generators-0.15.0 lib/generators/mustache/controller/controller_generator.rb
rails3-generators-0.14.0 lib/generators/mustache/controller/controller_generator.rb
rails3-generators-0.13.0 lib/generators/mustache/controller/controller_generator.rb
rails3-generators-0.12.1 lib/generators/mustache/controller/controller_generator.rb
rails3-generators-0.12.0 lib/generators/mustache/controller/controller_generator.rb
mustache_rails3-0.1.2.1 lib/generators/mustache/controller/controller_generator.rb
rails3-generators-0.11.0 lib/generators/mustache/controller/controller_generator.rb
rails3-generators-0.10.3 lib/generators/mustache/controller/controller_generator.rb
rails3-generators-0.10.2 lib/generators/mustache/controller/controller_generator.rb
rails3-generators-0.10.1 lib/generators/mustache/controller/controller_generator.rb