Rework template logic

ANSI escapes are now constants, so they are more readable
Re-instate the ERb logic that was previously lost