Permalink
Browse files

Added template engine support support

For now we only have template for erb
  • Loading branch information...
ashrafuzzaman committed Jun 16, 2012
1 parent ad1a560 commit 28a70329661b06bffdc4a5dcec6504a1ec616732
Showing with 15 additions and 15 deletions.
  1. +15 −15 lib/generators/nested_scaffold/nested_scaffold_generator.rb
@@ -21,11 +21,11 @@ def add_in_routes
def modify_view_files
template_eng = Rails.application.config.generators.options[:rails][:template_engine] || 'erb'
modify_edit_view(plural_table_name)
modify_form(plural_table_name)
modify_index_view(plural_table_name)
modify_show_view(plural_table_name)
modify_new_view(plural_table_name)
modify_edit_view(plural_table_name, template_eng)
modify_form(plural_table_name, template_eng)
modify_index_view(plural_table_name, template_eng)
modify_show_view(plural_table_name, template_eng)
modify_new_view(plural_table_name, template_eng)
end
protected
@@ -48,37 +48,37 @@ def modify_index_link(plural_table_name, file_name)
index_path
end
def modify_edit_view(plural_table_name)
file_name = "edit.html.erb"
def modify_edit_view(plural_table_name, template_eng)
file_name = "edit.html.#{template_eng}"
modify_resource_link(plural_table_name, file_name)
modify_index_link(plural_table_name, file_name)
end
def modify_form(plural_table_name)
file_name = "_form.html.erb"
def modify_form(plural_table_name, template_eng)
file_name = "_form.html.#{template_eng}"
gsub_file File.join("app/views", plural_table_name, file_name),
Regexp.new("(form_for.*)@#{singular_table_name}(.*do)"),
"\\1#{resource_path}\\2"
modify_index_link(plural_table_name, file_name)
end
def modify_index_view(plural_table_name)
file_name = "index.html.erb"
def modify_index_view(plural_table_name, template_eng)
file_name = "index.html.#{template_eng}"
modify_resource_link(plural_table_name, file_name)
modify_edit_link(plural_table_name, file_name)
gsub_file File.join("app/views", plural_table_name, file_name),
Regexp.new("new_#{singular_table_name}_path"),
"new_#{singular_path}(@#{pr.singular_table_name})"
end
def modify_show_view(plural_table_name)
file_name = "show.html.erb"
def modify_show_view(plural_table_name, template_eng)
file_name = "show.html.#{template_eng}"
modify_edit_link(plural_table_name, file_name)
modify_index_link(plural_table_name, file_name)
end
def modify_new_view(plural_table_name)
file_name = "new.html.erb"
def modify_new_view(plural_table_name, template_eng)
file_name = "new.html.#{template_eng}"
modify_index_link(plural_table_name, file_name)
end

0 comments on commit 28a7032

Please sign in to comment.