Extract the compiler parts

This seems like overkill if not for the desire to enable compile time reference checking. I'm not yet convinced it's a good idea -- the methods would need to be there when the template is first compiled, rather than when it is rendered. On the other hand, it would ensure that a compiled template would never get InvalidReferenceErrors, making input checking much easier for user provided templates.