Fix early return condition in getting template from cache.