DRY out some of the generated code

Trying to troubleshoot some of my generated templates, I was having a lot of trouble seeing through the boilerplate.

So I wrote a short extraction of the setup/try/catch, and added it to the main preamble.  The resulting template mappings now have reduced boilerplate.  I think there's more opportunity here, and may post additional updates if this is well received.