Don't call format() to build attributes.

This is just waste. I've yet to see any real reason to allow attribute
formatting to be templatable. Cutting this out saves numerous calls to
format() which can pile up and be expensive.
Add persistent caching to StringTemplate.

This in theory will remove the overhead around compiling templates on
each request.
Remove persistent cache.

It didn't actually increase performance at all. In some cases it would
slow things down as the filesystem was used.
Remove numerous calls to in_array().

Replacing in_array() with isset() saves a number of calls which add up
over time.
Merge pull request #4187 from markstory/string-template-cache

Optimize StringTemplate a bit