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

Commit

Permalink
nifty_authentication: adding haml support
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanb committed Nov 4, 2008
1 parent d309dc9 commit 89809fa
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ def manifest
m.template "user.rb", "app/models/#{user_singular_name}.rb"
m.template "users_controller.rb", "app/controllers/#{user_plural_name}_controller.rb"
m.template "users_helper.rb", "app/helpers/#{user_plural_name}_helper.rb"
m.template "views/erb/signup.html.erb", "app/views/#{user_plural_name}/new.html.erb"
m.template "views/#{view_language}/signup.html.#{view_language}", "app/views/#{user_plural_name}/new.html.#{view_language}"

m.directory "app/views/#{sessions_underscore_name}"
m.template "sessions_controller.rb", "app/controllers/#{sessions_underscore_name}_controller.rb"
m.template "sessions_helper.rb", "app/helpers/#{sessions_underscore_name}_helper.rb"
m.template "views/erb/login.html.erb", "app/views/#{sessions_underscore_name}/new.html.erb"
m.template "views/#{view_language}/login.html.#{view_language}", "app/views/#{sessions_underscore_name}/new.html.#{view_language}"

m.template "authentication.rb", "lib/authentication.rb"
m.migration_template "migration.rb", "db/migrate", :migration_file_name => "create_#{user_plural_name}"
Expand Down Expand Up @@ -86,7 +86,11 @@ def sessions_class_name
end

protected


def view_language
options[:haml] ? 'haml' : 'erb'
end

def test_framework
options[:test_framework] ||= File.exist?(destination_path("spec")) ? :rspec : :testunit
end
Expand All @@ -97,6 +101,7 @@ def add_options!(opt)
opt.on("--testunit", "Use test/unit for test files.") { options[:test_framework] = :testunit }
opt.on("--rspec", "Use RSpec for test files.") { options[:test_framework] = :rspec }
opt.on("--shoulda", "Use RSpec for test files.") { options[:test_framework] = :shoulda }
opt.on("--haml", "Generate HAML views instead of ERB.") { |v| options[:haml] = true }
end

def banner
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
- title "Log in"

%p
Don't have an account? #{link_to "Sign up!", signup_path}

- form_tag sessions_path do
%p
= label_tag :login, "Username or Email Address"
%br
= text_field_tag :login, params[:login]
%p
= label_tag :password
%br
= password_field_tag :password
%p
= submit_tag "Log in"
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
- title "Sign up"

%p
Already have an account? #{link_to "Log in", login_path}.

- form_for @<%= user_singular_name %> do |f|
= f.error_messages
%p
= f.label :username
%br
= f.text_field :username
%p
= f.label :email, "Email Address"
%br
= f.text_field :email
%p
= f.label :password
%br
= f.password_field :email
%p
= f.label :password_confirmation, "Confirm Password"
%br
= f.password_field :password_confirmation
%p
= f.submit "Sign up"
7 changes: 7 additions & 0 deletions test/test_nifty_authentication_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,12 @@ class TestNiftyAuthenticationGenerator < Test::Unit::TestCase
should_generate_file 'test/fixtures/users.yml'
end
end

context "generator with haml option" do
rails_generator :nifty_authentication, :haml => true

should_generate_file "app/views/users/new.html.haml"
should_generate_file "app/views/sessions/new.html.haml"
end
end
end

0 comments on commit 89809fa

Please sign in to comment.