Add template debug mode option. First pass at #3941

TODO: Tidy up options array.