advanced template loader