Sabberworm\CSS\CSSList\CSSList::render PHP Method

render() public method

public render ( Sabberworm\CSS\OutputFormat $oOutputFormat )
$oOutputFormat Sabberworm\CSS\OutputFormat
    public function render(\Sabberworm\CSS\OutputFormat $oOutputFormat)
    {
        $sResult = '';
        $bIsFirst = true;
        $oNextLevel = $oOutputFormat;
        if (!$this->isRootList()) {
            $oNextLevel = $oOutputFormat->nextLevel();
        }
        foreach ($this->aContents as $oContent) {
            $sRendered = $oOutputFormat->safely(function () use($oNextLevel, $oContent) {
                return $oContent->render($oNextLevel);
            });
            if ($sRendered === null) {
                continue;
            }
            if ($bIsFirst) {
                $bIsFirst = false;
                $sResult .= $oNextLevel->spaceBeforeBlocks();
            } else {
                $sResult .= $oNextLevel->spaceBetweenBlocks();
            }
            $sResult .= $sRendered;
        }
        if (!$bIsFirst) {
            // Had some output
            $sResult .= $oOutputFormat->spaceAfterBlocks();
        }
        return $sResult;
    }

Usage Example

Example #1
0
 public function render(\Sabberworm\CSS\OutputFormat $oOutputFormat)
 {
     $sResult = "@{$this->vendorKeyFrame} {$this->animationName}{$oOutputFormat->spaceBeforeOpeningBrace()}{";
     $sResult .= parent::render($oOutputFormat);
     $sResult .= '}';
     return $sResult;
 }