Skip to content
This repository has been archived by the owner on Oct 26, 2021. It is now read-only.

Commit

Permalink
Puts generated files in line with anticipated template handler
Browse files Browse the repository at this point in the history
Removes references to 'view' object;
Module-scopes view classes;
Adds detail link to index view;
Cleans up layout;
  • Loading branch information
goodmike committed Jun 23, 2010
1 parent 999c3b7 commit 3a05d9e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<p>Listing {{#<%= plural_name %>}}</p>
<p>Listing <%= plural_name.capitalize %></p>

<% for attribute in attributes -%>
<p><b><%= attribute.human_name %></b>: {{<%= attribute.name %>}}</p>
<% end -%>
{{#listing}}

{{/<%= plural_name %>}}
<p>
<% attributes.collect do |attribute| -%>
<b><%= attribute.human_name %></b>: {{<%= attribute.name %>}}
<% end.join(" | ") -%>
| <a href="{{show_path}}">Details</a></p>

{{/listing}}

<p><a href="{{new_path}}">New</a></p>
16 changes: 11 additions & 5 deletions lib/generators/mustache_generator/scaffold/templates/index.rb.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
class <%= plural_name %>Index < Mustache::Rails

def <%= plural_name %>
view.<%= plural_name %>
end
class <%= plural_name.camelize %>::Index < Mustache::Rails

def new_path
new_<%= singular_name %>_path()
end

def listing
<%= plural_name %>.collect do |record|
{
<% for attribute in attributes -%>
:<%= attribute.name %> => record.<%= attribute.name %>,
<% end -%>
:show_path => <%= singular_name %>_path(record)
}
end
end

end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p>Displaying <%= singular_name %></p>
<p>Displaying <%= singular_name.capitalize %></p>

<% for attribute in attributes -%>
<p><b><%= attribute.human_name %></b>: {{<%= attribute.name %>}}</p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class <%= class_name %>Show < Mustache::Rails
class <%= plural_name.camelize %>::Show < Mustache::Rails

<% for attribute in attributes -%>
def <%= attribute.name %>
view.<%= attribute.name %>
<%= singular_name %>.<%= attribute.name %>
end

<% end -%>
Expand Down

0 comments on commit 3a05d9e

Please sign in to comment.