Comment.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * Comment
  4. *
  5. * @package Less
  6. * @subpackage tree
  7. */
  8. class Less_Tree_Comment extends Less_Tree{
  9. public $value;
  10. public $silent;
  11. public $isReferenced;
  12. public $currentFileInfo;
  13. public $type = 'Comment';
  14. public function __construct($value, $silent, $index = null, $currentFileInfo = null ){
  15. $this->value = $value;
  16. $this->silent = !! $silent;
  17. $this->currentFileInfo = $currentFileInfo;
  18. }
  19. /**
  20. * @see Less_Tree::genCSS
  21. */
  22. public function genCSS( $output ){
  23. //if( $this->debugInfo ){
  24. //$output->add( tree.debugInfo($env, $this), $this->currentFileInfo, $this->index);
  25. //}
  26. $output->add( trim($this->value) );//TODO shouldn't need to trim, we shouldn't grab the \n
  27. }
  28. public function toCSS(){
  29. return Less_Parser::$options['compress'] ? '' : $this->value;
  30. }
  31. public function isSilent(){
  32. $isReference = ($this->currentFileInfo && isset($this->currentFileInfo['reference']) && (!isset($this->isReferenced) || !$this->isReferenced) );
  33. $isCompressed = Less_Parser::$options['compress'] && !preg_match('/^\/\*!/', $this->value);
  34. return $this->silent || $isReference || $isCompressed;
  35. }
  36. public function compile(){
  37. return $this;
  38. }
  39. public function markReferenced(){
  40. $this->isReferenced = true;
  41. }
  42. }