Skip to content

Instantly share code, notes, and snippets.

@aaronbbrown
Created November 2, 2012 13:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronbbrown/4001420 to your computer and use it in GitHub Desktop.
Save aaronbbrown/4001420 to your computer and use it in GitHub Desktop.
Debugging ERB Templates

Some tips on debugging ERB Templates

Convert the template to a ruby file

$ erb -x -T - file.erb > file.rb

Open the file. At the bottom, you'll see:

; _erbout

Add a puts in front of this, so instead of returning the output, it is displayed

; puts _erbout

If there are variables out of scope that need to be referenced, add them to the top. Now you can run the script directly and investigate the errors.

$ ruby file.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment