Value.php 812 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Value
  4. *
  5. * @package Less
  6. * @subpackage tree
  7. */
  8. class Less_Tree_Value extends Less_Tree {
  9. public $type = 'Value';
  10. public $value;
  11. public function __construct( $value ) {
  12. $this->value = $value;
  13. }
  14. public function accept( $visitor ) {
  15. $this->value = $visitor->visitArray( $this->value );
  16. }
  17. public function compile( $env ) {
  18. $ret = array();
  19. $i = 0;
  20. foreach ( $this->value as $i => $v ) {
  21. $ret[] = $v->compile( $env );
  22. }
  23. if ( $i > 0 ) {
  24. return new Less_Tree_Value( $ret );
  25. }
  26. return $ret[0];
  27. }
  28. /**
  29. * @see Less_Tree::genCSS
  30. */
  31. function genCSS( $output ) {
  32. $len = count( $this->value );
  33. for ( $i = 0; $i < $len; $i++ ) {
  34. $this->value[$i]->genCSS( $output );
  35. if ( $i + 1 < $len ) {
  36. $output->add( Less_Environment::$_outputMap[','] );
  37. }
  38. }
  39. }
  40. }