Add in some code to pre-template datastructures prior to template usage.  This prevents a certain class of error
where filter evaluations can happen too early due to the template engine recursion being a bit limited.

Addresses #4662