Skip to content
Rails scaffold generator that outputs Haml and better functional tests.
Ruby
Find file
Latest commit 4e5d910 Nov 12, 2009 @akahn akahn committed with Correct usage banner message.
Failed to load latest commit information.
config Converted to newgem. Feb 10, 2009
generators/haml_scaffold Correct usage banner message. Nov 12, 2009
lib/haml_scaffold
samples Upated generator code to Rails 2.3.2. Haml Scaffold now generates lay… Jul 1, 2009
.gitignore Upated generator code to Rails 2.3.2. Haml Scaffold now generates lay… Jul 1, 2009
History.txt Upated generator code to Rails 2.3.2. Haml Scaffold now generates lay… Jul 1, 2009
MIT-LICENSE Initial commit. Nov 7, 2008
Manifest.txt Upated generator code to Rails 2.3.2. Haml Scaffold now generates lay… Jul 1, 2009
README.rdoc Upated generator code to Rails 2.3.2. Haml Scaffold now generates lay… Jul 1, 2009
Rakefile Upated generator code to Rails 2.3.2. Haml Scaffold now generates lay… Jul 1, 2009
haml_scaffold.gemspec Upated generator code to Rails 2.3.2. Haml Scaffold now generates lay… Jul 1, 2009
init.rb

README.rdoc

Haml Scaffold

A collection of hacks to the Rails scaffold generator, to make it output templates using Haml rather than ERB. You may like some of it, and may hate other parts. You're free to use it under the terms of the MIT license if the parts you like outweigh the parts you hate.

This scaffold generator does the same thing as the default Rails scaffold generator, with a few differences.

Differences from Rails Scaffolding:

  • Haml not ERB.

Controller

  • Loads object with a before_filter to be DRYer.

  • “Destroy” method handles error conditions.

  • Actions are alphabetized for more obvious consistency.

  • Uses will_paginate.

Controller Test

  • Tests error conditions, not just the “happy path.”

  • Has 100% code coverage with RCov.

  • Uses very simple mocking with mocha to limit calls to the DB.

Views

  • Have cleaner, more semantic XHTML that's easier to quickly replace with your own markup.

  • Are broken up into a couple of partials to be DRYer.

  • Use will_paginate.

Misc

  • Generates Haml layout and SASS stylesheet.

Samples

View them here.

Installation

Haml Scaffold is available on RubyForge as a gem:

sudo gem install haml_scaffold

You can also install it as a Rails plugin if you wish:

./script/plugin install git://github.com/norman/haml-scaffold.git

Dependencies

The generated code will depend on:

You'll need to add the gem dependencies to your config/environment.rb manually:

config.gem "haml"
config.gem "will_paginate"
config.gem "mocha"

Also, don't forget to Hamlize your Rails app:

$ cd my_rails_app
$ haml --rails .

Other stuff you might be interested in:

Author

Norman Clarke

This work is derived from code in Ruby on Rails and is released under its same license, the MIT License.

Something went wrong with that request. Please try again.