protected function renderTag($tagName, array $attributes = [], $content = '')
    {
        if (empty($tagName)) {
            throw new \InvalidArgumentException('$tagName must not be NULL or empty.', 1343763729);
        }

        $output = '<' . htmlspecialchars($tagName);

        foreach ($attributes as $key => $value) {
            if (!is_string($key) || $key === '') {
                throw new \InvalidArgumentException('Attribute key must not be empty.', 1448657422);
            }
            $output .= ' ' . htmlspecialchars($key) . '="' . htmlspecialchars($value) . '"';
        }

        if ($content !== '') {
            $output .= '>' . $content . '</' . htmlspecialchars($tagName) . '>';
        } else {
            $output .= ' />';
        }

        return $output;
    }