Fix #20745: Don't silence TypeError raised inside templates.

Thanks to robin for the report and claudep for the review.