Wednesday, October 24, 2007

Multiview Templates in Rails 2.0

Along with many other enhancements and changes in Rails 2.0 now there are new multi view templates. I think multi view templates are going to be most visible and important change in Rails 2.0.

What essentially has happened is that template format has been separated from  rendering engine. This allows you to parse any type of template (csv, haml, rtf etc)  with erb rendering engine. So this takes respond_to  next level by having different template format for each respond_to.

So the new format for templates is action.format.renderer (i.e. show.html.erb, show.rtf.erb etc). you can declare own mime-type aliases in the config/initializers/mime_types.rb file. This file is included by default in all new applications.

For other new features coming in rails 2.0

http://weblog.rubyonrails.org/2007/9/30/rails-2-0-0-preview-release