Browse files

adding a generator (script/generate component)

  • Loading branch information...
1 parent 4f2b258 commit 41094e860ea8b4ce92b5e6e4c7ee611bcb1f8afd @cainlevy committed May 13, 2008
View
13 generators/component/component_generator.rb
@@ -0,0 +1,13 @@
+class ComponentGenerator < Rails::Generator::NamedBase
+ def manifest
+ record do |m|
+ m.class_collisions "#{class_name}Component"
+ m.directory "app/components/#{file_name}"
+ m.template "component_template.rb", "app/components/#{file_name}_component.rb"
+
+ actions.each do |action|
+ m.template "view_template.rb", "app/components/#{file_name}/#{action}.erb"
+ end
+ end
+ end
+end
View
7 generators/component/templates/component_template.rb
@@ -0,0 +1,7 @@
+class <%= class_name %>Component < Components::Base
+ <% actions.each do |action| %>
+ def <%= action %>
+ render
+ end
+ <% end %>
+end
View
0 generators/component/templates/view_template.rb
No changes.

0 comments on commit 41094e8

Please sign in to comment.