protected function renderTag($tagName, $content = null, array $attributes = [], array $nonEmptyAttributes = ['id', 'class'])
{
$trimmedContent = trim((string) $content);
$forceClosingTag = (bool) $this->arguments['forceClosingTag'];
if (true === empty($trimmedContent) && true === (bool) $this->arguments['hideIfEmpty']) {
return '';
}
if ('none' === $tagName || true === empty($tagName)) {
// skip building a tag if special keyword "none" is used, or tag name is empty
return $trimmedContent;
}
$this->tag->setTagName($tagName);
$this->tag->addAttributes($attributes);
$this->tag->forceClosingTag($forceClosingTag);
if (null !== $content) {
$this->tag->setContent($content);
}
// process some attributes differently - if empty, remove the property:
foreach ($nonEmptyAttributes as $propertyName) {
$value = $this->arguments[$propertyName];
if (true === empty($value)) {
$this->tag->removeAttribute($propertyName);
} else {
$this->tag->addAttribute($propertyName, $value);
}
}
return $this->tag->render();
}