Source of file SassCompressedRenderer.php
Size: 3,129 Bytes - Last Modified: 2021-12-23T10:32:55+00:00
/var/www/docs.ssmods.com/process/src/code/phpsass/renderers/SassCompressedRenderer.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 | <?php /* SVN FILE: $Id$ */ /** * SassCompressedRenderer class file. * @author Chris Yates <chris.l.yates@gmail.com> * @copyright Copyright (c) 2010 PBM Web Development * @license http://phamlp.googlecode.com/files/license.txt * @package PHamlP * @subpackage Sass.renderers */ /** * SassCompressedRenderer class. * Compressed style takes up the minimum amount of space possible, having no * whitespace except that necessary to separate selectors and a newline at the * end of the file. It's not meant to be human-readable * @package PHamlP * @subpackage Sass.renderers */ class SassCompressedRenderer extends SassRenderer { /** * Renders the brace between the selectors and the properties * @return string the brace between the selectors and the properties */ protected function between() { return '{'; } /** * Renders the brace at the end of the rule * @return string the brace between the rule and its properties */ protected function end() { return '}'; } /** * Returns the indent string for the node * @param SassNode the node to return the indent string for * @return string the indent string for this SassNode */ protected function getIndent($node) { return ''; } /** * Renders a comment. * @param SassNode the node being rendered * @return string the rendered comment */ public function renderComment($node) { return ''; } /** * Renders a directive. * @param SassNode the node being rendered * @param array properties of the directive * @return string the rendered directive */ public function renderDirective($node, $properties) { return $node->directive . $this->between() . $this->renderProperties($node, $properties) . $this->end(); } /** * Renders properties. * @param SassNode the node being rendered * @param array properties to render * @return string the rendered properties */ public function renderProperties($node, $properties) { return join('', $properties); } /** * Renders a property. * @param SassNode the node being rendered * @return string the rendered property */ public function renderProperty($node) { return "{$node->name}:{$node->value};"; } /** * Renders a rule. * @param SassNode the node being rendered * @param array rule properties * @param string rendered rules * @return string the rendered directive */ public function renderRule($node, $properties, $rules) { $selectors = $this->renderSelectors($node); if ($selectors) { return (!empty($properties) ? $selectors . $this->between() . $this->renderProperties($node, $properties) . $this->end() : '') . $rules; } } /** * Renders the rule's selectors * @param SassNode the node being rendered * @return string the rendered selectors */ protected function renderSelectors($node) { $selectors = array(); foreach ($node->selectors as $selector) { if (!$node->isPlaceholder($selector)) { $selectors[] = $selector; } } return join(',', $selectors); } } |