Keep the parser's template depth up to date when parsing local templates and
late-parsed templates. Patch by Faisal Vali!