Add template debug mode option. First pass at #3941
Merge pull request #3992 from scottbasgaard/master

Add template debug mode option. First pass at #3941