add a more restricted codepath for templates fixes #13390