Skip to content

Commit

Permalink
Updated all scaffold related views so it uses I18n.
Browse files Browse the repository at this point in the history
  • Loading branch information
thhermansen authored and psynix committed Jun 28, 2010
1 parent 911c229 commit 525f191
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 24 deletions.
11 changes: 8 additions & 3 deletions README.markdown
@@ -1,10 +1,15 @@
# Rails 3 HAML Scaffold Generator
# Information about this fork

This for is no longer following the normal scaffolding layout of Rails.
It uses I18n backend for headings, model attributes names etc in it's views.

## Rails 3 HAML Scaffold Generator

Essentially just a copy of the Rails 3 ERB generator with HAML replacements for the templates.

Original idea from [Paul Barry's article on custom genrators][OriginalIdea]

## Installation
### Installation

1. Generate your new rails application:

Expand Down Expand Up @@ -55,4 +60,4 @@ Original idea from [Paul Barry's article on custom genrators][OriginalIdea]

* Gemify (?)

[OriginalIdea]: http://paulbarry.com/articles/2010/01/13/customizing-generators-in-rails-3
[OriginalIdea]: http://paulbarry.com/articles/2010/01/13/customizing-generators-in-rails-3
8 changes: 4 additions & 4 deletions scaffold/templates/edit.html.haml
@@ -1,5 +1,5 @@
%h1 Editing <%= singular_name %>

%h1= t '.title'
%p
= link_to t('back'), <%= plural_name %>_path
= link_to t('show'), @<%= singular_name %>
= render 'form'

== #{ link_to 'Show', @<%= singular_name %> } | #{ link_to 'Back', <%= plural_name %>_path }
14 changes: 6 additions & 8 deletions scaffold/templates/index.html.haml
@@ -1,10 +1,11 @@
%h1 Listing <%= plural_name %>
%h1= t('.title')
%p= link_to t('.new_<%= singular_name %>'), new_<%= singular_name %>_path

%table
%thead
%tr
<% for attribute in attributes -%>
%th <%= attribute.human_name %>
%th= <%= class_name %>.human_attribute_name :<%= attribute %>
<% end -%>
%th{ :colspan => 3 }

Expand All @@ -14,9 +15,6 @@
<% for attribute in attributes -%>
%td= <%= singular_name %>.<%= attribute.name %>
<% end -%>
%td= link_to 'Show', <%= singular_name %>
%td= link_to 'Edit', edit_<%= singular_name %>_path(<%= singular_name %>)
%td= link_to 'Destroy', <%= singular_name %>, :confirm => 'Are you sure?', :method => :delete

%br
= link_to 'New <%= singular_name %>', new_<%= singular_name %>_path
%td.action= link_to t('show'), <%= singular_name %>
%td.action= link_to t('edit'), edit_<%= singular_name %>_path(<%= singular_name %>)
%td.action= link_to t('destroy'), <%= singular_name %>, :confirm => t('are_you_sure'), :method => :delete
6 changes: 2 additions & 4 deletions scaffold/templates/new.html.haml
@@ -1,5 +1,3 @@
%h1 New <%= singular_name %>

%h1= t '.title'
%p= link_to t('back'), <%= plural_name %>_path
= render 'form'

= link_to 'Back', <%= plural_name %>_path
13 changes: 8 additions & 5 deletions scaffold/templates/show.html.haml
@@ -1,7 +1,10 @@
<% for attribute in attributes -%>
%h1= t '.title'
%p
%strong <%= attribute.human_name %>:
= @<%= singular_name %>.<%= attribute.name %>
<% end -%>
= link_to t('back'), <%= plural_name %>_path
= link_to t('edit'), edit_<%= singular_name %>_path(@<%= singular_name %>)

== #{ link_to 'Edit', edit_<%= singular_name %>_path(@<%= singular_name %>) } | #{ link_to 'Back', <%= plural_name %>_path }
%dl
<% for attribute in attributes -%>
%dt= <%= class_name %>.human_attribute_name :<%= attribute %>
%dd= @<%= singular_name %>.<%= attribute.name %>
<% end -%>

0 comments on commit 525f191

Please sign in to comment.