You are here

class SassRootNode in Sassy 7

Same name and namespace in other branches
  1. 7.3 phpsass/tree/SassRootNode.php \SassRootNode

SassRootNode class. Also the root node of a document. @package PHamlP @subpackage Sass.tree

Hierarchy

Expanded class hierarchy of SassRootNode

File

phamlp/sass/tree/SassRootNode.php, line 21

View source
class SassRootNode extends SassNode {

  /**
   * @var SassScriptParser SassScript parser
   */
  protected $script;

  /**
   * @var SassRenderer the renderer for this node
   */
  protected $renderer;

  /**
   * @var SassParser
   */
  protected $parser;

  /**
   * @var array extenders for this tree in the form extendee=>extender
   */
  protected $extenders = array();

  /**
   * Root SassNode constructor.
   * @param SassParser Sass parser
   * @return SassNode
   */
  public function __construct($parser) {
    parent::__construct((object) array(
      'source' => '',
      'level' => -1,
      'filename' => $parser->filename,
      'line' => 0,
    ));
    $this->parser = $parser;
    $this->script = new SassScriptParser();
    $this->renderer = SassRenderer::getRenderer($parser->style);
    $this->root = $this;
  }

  /**
   * Parses this node and its children into the render tree.
   * Dynamic nodes are evaluated, files imported, etc.
   * Only static nodes for rendering are in the resulting tree.
   * @param SassContext the context in which this node is parsed
   * @return SassNode root node of the render tree
   */
  public function parse($context) {
    $node = clone $this;
    $node->children = $this
      ->parseChildren($context);
    return $node;
  }

  /**
   * Render this node.
   * @return string the rendered node
   */
  public function render() {
    $node = $this
      ->parse(new SassContext());
    $output = '';
    foreach ($node->children as $child) {
      $output .= $child
        ->render();
    }

    // foreach
    return $output;
  }
  public function extend($extendee, $selectors) {
    $this->extenders[$extendee] = isset($this->extenders[$extendee]) ? array_merge($this->extenders[$extendee], $selectors) : $selectors;
  }
  public function getExtenders() {
    return $this->extenders;
  }

  /**
   * Returns a value indicating if the line represents this type of node.
   * Child classes must override this method.
   * @throws SassNodeException if not overriden
   */
  public static function isa($line) {
    throw new SassNodeException('Child classes must override this method');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SassNode::$children protected property *
SassNode::$parent protected property *
SassNode::$root protected property *
SassNode::$token protected property *
SassNode::addChild public function * Adds a child to this node. *
SassNode::addWarning public function * Adds a warning to the node. *
SassNode::evaluate protected function * Evaluates a SassScript expression. *
SassNode::getChildren public function * Returns the node's children *
SassNode::getDebug_info private function * Returns the debug_info option setting for this node *
SassNode::getFilename private function * Returns the filename for this node *
SassNode::getLastChild public function * Returns the last child node of this node. *
SassNode::getLevel private function * Returns the level of this node. *
SassNode::getLine private function * Returns the line number for this node *
SassNode::getLine_numbers private function * Returns the line_numbers option setting for this node *
SassNode::getParent public function * Returns the node's parent *
SassNode::getParser public function * Returns the Sass parser. *
SassNode::getPropertySyntax public function * Returns the property syntax being used. *
SassNode::getRenderer public function * Returns the renderer. *
SassNode::getScript public function * Returns the SassScript parser. *
SassNode::getSource private function * Returns the source for this node *
SassNode::getStyle public function * Returns the render style of the document tree. *
SassNode::getVendor_properties private function * Returns vendor specific properties *
SassNode::hasChildren public function * Returns a value indicating if this node has children *
SassNode::hasParent public function * Return a value indicating if this node has a parent *
SassNode::inDirective public function * Returns a value indicating whether this node is in a directive *
SassNode::inSassScriptDirective public function * Returns a value indicating whether this node is in a SassScript directive *
SassNode::interpolate protected function * Replace interpolated SassScript contained in '#{}' with the parsed value. *
SassNode::isChildOf public function * Returns a value indicating if this node is a child of the passed node. * This just checks the levels of the nodes. If this node is at a greater * level than the passed node if is a child of it. *
SassNode::parseChildren protected function * Parse the children of the node. *
SassNode::__clone public function * Resets children when cloned *
SassNode::__get public function * Getter. *
SassNode::__set public function * Setter. *
SassRootNode::$extenders protected property *
SassRootNode::$parser protected property *
SassRootNode::$renderer protected property *
SassRootNode::$script protected property *
SassRootNode::extend public function
SassRootNode::getExtenders public function
SassRootNode::isa public static function * Returns a value indicating if the line represents this type of node. * Child classes must override this method. * Overrides SassNode::isa
SassRootNode::parse public function * Parses this node and its children into the render tree. * Dynamic nodes are evaluated, files imported, etc. * Only static nodes for rendering are in the resulting tree. *
SassRootNode::render public function * Render this node. *
SassRootNode::__construct public function * Root SassNode constructor. * Overrides SassNode::__construct