Skip to content

Instantly share code, notes, and snippets.

@tizoc
Created April 20, 2011 13:40
Show Gist options
  • Save tizoc/931350 to your computer and use it in GitHub Desktop.
Save tizoc/931350 to your computer and use it in GitHub Desktop.
erb_template = ERB.new(template_string) # Compiles template_string to ruby code that generates the output
erb_template.result # Slow, calls eval on the compiled string every time you call render
erb_proc = eval("Proc.new{#{erb_template.src}}")
erb_proc.call # Fast, calls the code directly, no eval involved when generating the output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment