Improved precompile template version check

This check reduces duplicated code as well as also failing if the template
was precompiled on a version before the check was added.