Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
 public function render(\Sabberworm\CSS\OutputFormat $oOutputFormat)
 {
     $sResult = '';
     $bIsFirst = true;
     foreach ($this->aRules as $aRules) {
         foreach ($aRules as $oRule) {
             $sRendered = $oOutputFormat->safely(function () use($oRule, $oOutputFormat) {
                 return $oRule->render($oOutputFormat->nextLevel());
             });
             if ($sRendered === null) {
                 continue;
             }
             if ($bIsFirst) {
                 $bIsFirst = false;
                 $sResult .= $oOutputFormat->nextLevel()->spaceBeforeRules();
             } else {
                 $sResult .= $oOutputFormat->nextLevel()->spaceBetweenRules();
             }
             $sResult .= $sRendered;
         }
     }
     if (!$bIsFirst) {
         // Had some output
         $sResult .= $oOutputFormat->spaceAfterRules();
     }
     return $oOutputFormat->removeLastSemicolon($sResult);
 }