/**
* Renders the inline element
*
* @param WebAssetItemInterface|array $item The element
*
* @return string The resulting string
*
* @since 4.0.0
*/
private function renderInlineElement($item) : string
{
$buffer = '';
$lnEnd = $this->_doc->_getLineEnd();
$tab = $this->_doc->_getTab();
if ($item instanceof WebAssetItemInterface) {
$attribs = $item->getAttributes();
$content = $item->getOption('content');
} else {
$attribs = $item;
$content = $item['content'] ?? '';
unset($attribs['content']);
}
// Do not produce empty elements
if (!$content) {
return '';
}
// Add "nonce" attribute if exist
if ($this->_doc->cspNonce) {
$attribs['nonce'] = $this->_doc->cspNonce;
}
$buffer .= $tab . '<style';
$buffer .= $this->renderAttributes($attribs);
$buffer .= '>';
// This is for full XHTML support.
if ($this->_doc->_mime !== 'text/html') {
$buffer .= $tab . $tab . '/*<![CDATA[*/' . $lnEnd;
}
$buffer .= $content;
// See above note
if ($this->_doc->_mime !== 'text/html') {
$buffer .= $tab . $tab . '/*]]>*/' . $lnEnd;
}
$buffer .= '</style>' . $lnEnd;
return $buffer;
}