private function validateTemplate($template, $templateList)
    {
        if (empty($template)) {
            throw new \Exception('The template name is required.');
        }

        if (!in_array($template, $templateList)) {
            throw new \InvalidArgumentException(
                sprintf('The template "%s" does not exist, use: %s', $template, implode(', ', $templateList))
            );
        }
    }