You are here

class HamlNestedRenderer in Sassy 7

HamlNestedRenderer class. Blocks and content are indented according to their nesting level. @package PHamlP @subpackage Haml.renderers

Hierarchy

Expanded class hierarchy of HamlNestedRenderer

File

phamlp/haml/renderers/HamlNestedRenderer.php, line 18

View source
class HamlNestedRenderer extends HamlRenderer {

  /**
   * Renders the opening tag of an element
   */
  public function renderOpeningTag($node) {
    return ($node->whitespaceControl['outer'] ? '' : $this
      ->getIndent($node)) . parent::renderOpeningTag($node) . ($node->whitespaceControl['inner'] ? '' : ($node->isSelfClosing && $node->whitespaceControl['outer'] ? '' : "\n"));
  }

  /**
   * Renders the closing tag of an element
   */
  public function renderClosingTag($node) {
    return $node->isSelfClosing ? '' : ($node->whitespaceControl['inner'] ? '' : $this
      ->getIndent($node)) . parent::renderClosingTag($node) . ($node->whitespaceControl['outer'] ? '' : "\n");
  }

  /**
   * Renders content.
   * @param HamlNode the node being rendered
   * @return string the rendered content
   */
  public function renderContent($node) {
    return $this
      ->getIndent($node) . parent::renderContent($node) . "\n";
  }

  /**
   * Renders the opening of a comment
   */
  public function renderOpenComment($node) {
    return parent::renderOpenComment($node) . (empty($node->content) ? "\n" : '');
  }

  /**
   * Renders the closing of a comment
   */
  public function renderCloseComment($node) {
    return parent::renderCloseComment($node) . "\n";
  }

  /**
   * Renders the start of a code block
   */
  public function renderStartCodeBlock($node) {
    return $this
      ->getIndent($node) . parent::renderStartCodeBlock($node) . "\n";
  }

  /**
   * Renders the end of a code block
   */
  public function renderEndCodeBlock($node) {
    return $this
      ->getIndent($node) . parent::renderEndCodeBlock($node) . "\n";
  }
  private function getIndent($node) {
    return str_repeat(' ', 2 * $node->level);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
HamlNestedRenderer::getIndent private function
HamlNestedRenderer::renderCloseComment public function * Renders the closing of a comment Overrides HamlRenderer::renderCloseComment
HamlNestedRenderer::renderClosingTag public function * Renders the closing tag of an element Overrides HamlRenderer::renderClosingTag
HamlNestedRenderer::renderContent public function * Renders content. * Overrides HamlRenderer::renderContent
HamlNestedRenderer::renderEndCodeBlock public function * Renders the end of a code block Overrides HamlRenderer::renderEndCodeBlock
HamlNestedRenderer::renderOpenComment public function * Renders the opening of a comment Overrides HamlRenderer::renderOpenComment
HamlNestedRenderer::renderOpeningTag public function * Renders the opening tag of an element Overrides HamlRenderer::renderOpeningTag
HamlNestedRenderer::renderStartCodeBlock public function * Renders the start of a code block Overrides HamlRenderer::renderStartCodeBlock
HamlRenderer::$attrWrapper private property
HamlRenderer::$format private property
HamlRenderer::$minimizedAttributes private property
HamlRenderer::getRenderer public static function * Returns the renderer for the required render style. *
HamlRenderer::INDENT constant
HamlRenderer::renderAttributes private function * Renders element attributes
HamlRenderer::STYLE_COMPACT constant
HamlRenderer::STYLE_COMPRESSED constant
HamlRenderer::STYLE_EXPANDED constant
HamlRenderer::STYLE_NESTED constant
HamlRenderer::__construct public function