Further hardening. Refs #18766.
Removed some more unused local vars
Fix #20745: Don't silence TypeError raised inside templates.

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