public
Description: Compile time optimization of Rails rhtml templates
Homepage:
Clone URL: git://github.com/skaes/template_optimizer.git
name age message
file LICENSE Sun Aug 13 22:49:35 -0700 2006 template optimizer import [skaes]
file README Thu Aug 17 11:33:24 -0700 2006 plugin installation is currently broken [skaes]
file Rakefile Sun Aug 13 22:49:35 -0700 2006 template optimizer import [skaes]
file TODO Sat Sep 09 00:59:07 -0700 2006 more todos [skaes]
file init.rb Fri Sep 01 09:15:21 -0700 2006 bug fixes for: block inlining; problems with pl... [skaes]
directory lib/ Thu Jan 10 01:02:47 -0800 2008 updated copyright notices [skaes]
README
== Welcome to the Rails Template Optimizer

The Rails Template Optimizer was designed to greatly enhance the
performance of the rendering engine built into Rails.

The Rails Template Optimizer is available under the GPL LICENCE.


== Requirements

The template optimizer depends on the functionality of Ryan Davis'
ParseTree package, which in turn requires his RubyInline package.

You can either download and install these, or obtain a standalone
version of ParseTree from http://www.railsexpress.de/downloads.

The advantage of the second option is that you won't need a C compiler
on your production system.


== Getting started

1. Install the software package into some directory of your choice <DIR>.
2. Add "require <DIR>/init.rb" to the end of <tt>RAILS_ROOT/config/environment.rb</tt>.
3. Create directory <tt>RAILS_ROOT/tmp/templates</tt> with appropriate permissions.
4. Optional: add configuration code to <tt>RAILS_ROOT/config/environment.rb</tt>

Alternatively you can install the template optimizer in the plugin
directory of your Rails app.

NOTE: plugin support is currently broken, but will be fixed eventually.


== How it works

Whenever the code for a Rails template gets compiled, the Rails
Template Optimizer gets invoked in the context of the current
controller's view class, with the name of the compiled render
method. It then retrieves the abstract syntax tree of the render
method, processes it according to a set of configured optimization
options, creates Ruby source code from the transformed tree and
evaluates the new source to obtain an optimized version of the
original method.

NOTE: you might want to make sure that the Template Optimizer doesn't
run in development mode.


== Watching it perform

The original source code of a render method <tt>m</tt> gets logged to
<tt>RAILS_ROOT/tmp/templates/m.src</tt>. The code for the optimized
method is written to <tt>RAILS_ROOT/tmp/templates/m.rb</tt>.

Log information produced by the template optimizer is prefixed by the
string "TO: ", which makes it easy to seach your log for optimizer
problems.


== Safety hazards

The original render method will be used by your app if optimization
raises an exception. In rare cases, where the improved code doesn't
perform the way it should (raises exceptions or produces wrong
results), optimization can be turned off for selected templates by
specifying a list of regular expressions for method names which should
be exempted from optimization.