You are here

class SassNestedRenderer in Sassy 7

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

SassNestedRenderer class. Nested style is the default Sass style, because it reflects the structure of the document in much the same way Sass does. Each rule is indented based on how deeply it's nested. Each property has its own line and is indented within the rule. @package PHamlP @subpackage Sass.renderers

Hierarchy

Expanded class hierarchy of SassNestedRenderer

File

phamlp/sass/renderers/SassNestedRenderer.php, line 23

View source
class SassNestedRenderer extends SassExpandedRenderer {

  /**
   * Renders the brace at the end of the rule
   * @return string the brace between the rule and its properties
   */
  protected function end() {
    return " }\n";
  }

  /**
   * Returns the indent string for the node
   * @param SassNode the node being rendered
   * @return string the indent string for this SassNode
   */
  protected function getIndent($node) {
    return str_repeat(self::INDENT, $node->level);
  }

  /**
   * 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) {
    $directive = $this
      ->getIndent($node) . $node->directive . $this
      ->between() . $this
      ->renderProperties($node, $properties);
    return preg_replace('/(.*})\\n$/', '\\1', $directive) . $this
      ->end();
  }

  /**
   * Renders rule selectors.
   * @param SassNode the node being rendered
   * @return string the rendered selectors
   */
  protected function renderSelectors($node) {
    $indent = $this
      ->getIndent($node);
    return $indent . join(",\n{$indent}", $node->selectors);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SassCompactRenderer::DEBUG_INFO_PROPERTY constant
SassCompactRenderer::DEBUG_INFO_RULE constant
SassCompactRenderer::renderDebug protected function * Renders debug information. * If the node has the debug_info options set true the line number and filename * are rendered in a format compatible with * {@link https://addons.mozilla.org/en-US/firefox/addon/103988/ FireSass}. * Else if the…
SassCompactRenderer::renderProperty public function * Renders a property. * Overrides SassCompressedRenderer::renderProperty
SassCompactRenderer::renderRule public function * Renders a rule. * Overrides SassCompressedRenderer::renderRule
SassExpandedRenderer::between protected function * Renders the brace between the selectors and the properties * Overrides SassCompactRenderer::between
SassExpandedRenderer::renderComment public function * Renders a comment. * Overrides SassCompactRenderer::renderComment
SassExpandedRenderer::renderProperties public function * Renders properties. * Overrides SassCompactRenderer::renderProperties
SassNestedRenderer::end protected function * Renders the brace at the end of the rule * Overrides SassExpandedRenderer::end
SassNestedRenderer::getIndent protected function * Returns the indent string for the node * Overrides SassCompressedRenderer::getIndent
SassNestedRenderer::renderDirective public function * Renders a directive. * Overrides SassCompactRenderer::renderDirective
SassNestedRenderer::renderSelectors protected function * Renders rule selectors. * Overrides SassCompactRenderer::renderSelectors
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