Move template processing substitutions to TemplateProcessor
Check that location is not null before adding to substitutions
Merge pull request #1085 from grkvlt/fix/template-processor-substitutions

Added null check as suggested. Merging.