Only store template name after correct match.
Fixes a bug where a failed template expansion would leave the template name in template_info.