You are here

class SassCompressedRenderer in Sassy 7

Same name and namespace in other branches
  1. 7.3 phpsass/renderers/SassCompressedRenderer.php \SassCompressedRenderer

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

Hierarchy

Expanded class hierarchy of SassCompressedRenderer

File

phamlp/sass/renderers/SassCompressedRenderer.php, line 19

View source
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) {
    return (!empty($properties) ? $this
      ->renderSelectors($node) . $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) {
    return join(',', $node->selectors);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SassCompressedRenderer::between protected function * Renders the brace between the selectors and the properties * 1
SassCompressedRenderer::end protected function * Renders the brace at the end of the rule * 1
SassCompressedRenderer::getIndent protected function * Returns the indent string for the node * 1
SassCompressedRenderer::renderComment public function * Renders a comment. * 1
SassCompressedRenderer::renderDirective public function * Renders a directive. * 1
SassCompressedRenderer::renderProperties public function * Renders properties. * 1
SassCompressedRenderer::renderProperty public function * Renders a property. * 1
SassCompressedRenderer::renderRule public function * Renders a rule. * 1
SassCompressedRenderer::renderSelectors protected function * Renders the rule's selectors * 1
SassRenderer::getRenderer public static function * Returns the renderer for the required render style. *
SassRenderer::INDENT constant
SassRenderer::STYLE_COMPACT constant
SassRenderer::STYLE_COMPRESSED constant
SassRenderer::STYLE_EXPANDED constant
SassRenderer::STYLE_NESTED constant