class ActionView::Template

def compile!(view)

just once and removes the source after it is compiled.
Compile a template. This method ensures a template is compiled
def compile!(view)
  return if @compiled
  # Templates can be used concurrently in threaded environments
  # so compilation and any instance variable modification must
  # be synchronized
  @compile_mutex.synchronize do
    # Any thread holding this lock will be compiling the template needed
    # by the threads waiting. So re-check the @compiled flag to avoid
    # re-compilation
    return if @compiled
    mod = view.compiled_method_container
    instrument("!compile_template") do
      compile(mod)
    end
    @compiled = true
  end
end