Cache template paths in a local variable.

Cache the possible template paths in `locate_template()` so they don't have to be regenerated while looping through a list of templates.