<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -187,6 +187,11 @@ module Tilt
   # ERB template implementation. See:
   # http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html
   class ERBTemplate &lt; Template
+    def initialize(*args)
+      super
+      @template_procs = {}
+    end
+
     def compile!
       require_template_library 'erb' unless defined?(::ERB)
       @engine = ::ERB.new(data, options[:safe], options[:trim], '@_out_buf')
@@ -197,14 +202,11 @@ module Tilt
     end
 
     def evaluate(scope, locals, &amp;block)
-      source, offset = local_assignment_code(locals)
-      source = [source, template_source].join(&quot;\n&quot;)
-
       original_out_buf =
         scope.instance_variables.any? { |var| var.to_sym == :@_out_buf } &amp;&amp;
         scope.instance_variable_get(:@_out_buf)
 
-      scope.instance_eval source, eval_file, line - offset
+      scope.instance_eval(&amp;template_proc(locals))
 
       output = scope.instance_variable_get(:@_out_buf)
       scope.instance_variable_set(:@_out_buf, original_out_buf)
@@ -213,6 +215,13 @@ module Tilt
     end
 
   private
+    def template_proc(locals)
+      @template_procs[locals] ||= begin
+        source, offset = local_assignment_code(locals)
+        source = [source, template_source].join(&quot;\n&quot;)
+        instance_eval(&quot;proc { #{source} }&quot;, eval_file, line - offset)
+      end
+    end
 
     # ERB generates a line to specify the character coding of the generated
     # source in 1.9. Account for this in the line offset.</diff>
      <filename>lib/tilt.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>1fdc1bfe7d3944494bdc6182f58690c1e690d411</id>
    </parent>
  </parents>
  <author>
    <name>Joshua Peek</name>
    <email>josh@joshpeek.com</email>
  </author>
  <url>http://github.com/rtomayko/tilt/commit/d1470105551106d4e0a2f3e65b569b01caf54af6</url>
  <id>d1470105551106d4e0a2f3e65b569b01caf54af6</id>
  <committed-date>2009-11-06T14:41:17-08:00</committed-date>
  <authored-date>2009-11-06T14:41:17-08:00</authored-date>
  <message>Cached compiled erb templates in procs</message>
  <tree>1ad9b17bbacdcda6e3a3373202a0eaaed8001ccd</tree>
  <committer>
    <name>Joshua Peek</name>
    <email>josh@joshpeek.com</email>
  </committer>
</commit>
