Support for caching compiled templates

Fixes #3