Sha256: e0ca1347f40b08b5145ab3855434c8120fc6c9d69c8403638cbd12b4a3fba417
Contents?: true
Size: 1.16 KB
Versions: 4
Compression:
Stored size: 1.16 KB
Contents
require 'rails_generator/generators/components/controller/controller_generator' class WidgetGenerator < ControllerGenerator def add_options!(opt) opt.on('--haml') { |value| options[:view_format] = 'haml' } end def manifest options.reverse_merge! :view_format => 'erb' record do |m| # Check for class naming collisions. m.class_collisions class_path, "#{class_name}" # Directories m.directory File.join('app/cells', class_path) m.directory File.join('app/cells', class_path, file_name) m.directory File.join('test/widgets') # Widget m.template 'widget.rb', File.join('app/cells', class_path, "#{file_name}.rb") # View template for each state. format = options[:view_format] actions.each do |state| path = File.join('app/cells', class_path, file_name, "#{state}.html.#{format}") m.template "view.html.#{format}", path, :assigns => { :action => state, :path => path } end # Functional test for the widget. m.template 'functional_test.rb', File.join('test/widgets/', "#{file_name}_test.rb"), :assigns => {:states => actions} end end end
Version data entries
4 entries across 4 versions & 1 rubygems