Skip to content

Instantly share code, notes, and snippets.

@Fjan
Fjan / erubis_preprocessing.rb
Created November 20, 2010 00:19
Enable preprocessing in erubis with the <%=== %> directive
# Just drop this in the initializers directory of a rails 3 app and then use <%=== code %> in your templates
# and the code will be eval'ed at compile time, for example: <%=== link_to 'home', '/' %> actually puts
# <a href="/">home</a> in the compiled template avoiding the need to call link_to on every render
# This can provide a significant speedup of your rails views but beware that many rails helpers can produce
# different output depending on the context that is not available at compile time.
# For example, @form.text_field :name would produce different HTML if there was an error on the :name field.
# It doesn't work yet on asset tags like <%= javascript_include_tag :default %>
module ActionView