Rewrite ERB compiler to be easier to follow (#346)

The previous ERB compiler was a mess. This commit makes it easier to
follow and read. It also makes it overridable, if we ever wish to.