Sha256: fbca1670dfd6bbba18bc85b29680cfa4111de2105e38feb6a158f2252f1628bb

Contents?: true

Size: 1.48 KB

Versions: 3

Compression:

Stored size: 1.48 KB

Contents

<?php
/* SVN FILE: $Id: SassCommentNode.php 49 2010-04-04 10:51:24Z chris.l.yates $ */
/**
 * SassCommentNode 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.tree
 */

/**
 * SassCommentNode class.
 * Represents a CSS comment.
 * @package			PHamlP
 * @subpackage	Sass.tree
 */
class SassCommentNode extends SassNode {
	const NODE_IDENTIFIER = '/';
	const MATCH = '%^/\*\s*(.*?)\s*(\*/)?$%s';
	const COMMENT = 1;
	
	private $value; 
	
	/**
	 * SassCommentNode constructor.
	 * @param object source token
	 * @return CommentNode
	 */
	public function __construct($token) {
		parent::__construct($token);		
		preg_match(self::MATCH, $token->source, $matches);
		$this->value = $matches[self::COMMENT];
	}
	
	protected function getValue() {
		return $this->value; 
	} 

	/**
	 * Parse this node.
	 * @return array the parsed node - an empty array
	 */
	public function parse($context) {
		return array($this);
	}

	/**
	 * Render this node.
	 * @return string the rendered node
	 */
	public function render() {
		return $this->renderer->renderComment($this);
	}

	/**
	 * Returns a value indicating if the token represents this type of node.
	 * @param object token
	 * @return boolean true if the token represents this type of node, false if not
	 */
	public static function isa($token) {
		return $token->source[0] === self::NODE_IDENTIFIER;
	}
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
frontsau-0.0.3 lib/Phamlp/sass/tree/SassCommentNode.php
frontsau-0.0.2 lib/Phamlp/sass/tree/SassCommentNode.php
frontsau-0.0.1 lib/Phamlp/sass/tree/SassCommentNode.php