NameValue.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * A simple css name-value pair
  4. * ex: width:100px;
  5. *
  6. * In bootstrap, there are about 600-1,000 simple name-value pairs (depending on how forgiving the match is) -vs- 6,020 dynamic rules (Less_Tree_Rule)
  7. * Using the name-value object can speed up bootstrap compilation slightly, but it breaks color keyword interpretation: color:red -> color:#FF0000;
  8. *
  9. * @package Less
  10. * @subpackage tree
  11. */
  12. class Less_Tree_NameValue extends Less_Tree {
  13. public $name;
  14. public $value;
  15. public $index;
  16. public $currentFileInfo;
  17. public $type = 'NameValue';
  18. public $important = '';
  19. public function __construct( $name, $value = null, $index = null, $currentFileInfo = null ) {
  20. $this->name = $name;
  21. $this->value = $value;
  22. $this->index = $index;
  23. $this->currentFileInfo = $currentFileInfo;
  24. }
  25. public function genCSS( $output ) {
  26. $output->add(
  27. $this->name
  28. . Less_Environment::$_outputMap[': ']
  29. . $this->value
  30. . $this->important
  31. . ( ( ( Less_Environment::$lastRule && Less_Parser::$options['compress'] ) ) ? "" : ";" ),
  32. $this->currentFileInfo, $this->index );
  33. }
  34. public function compile( $env ) {
  35. return $this;
  36. }
  37. public function makeImportant() {
  38. $new = new Less_Tree_NameValue( $this->name, $this->value, $this->index, $this->currentFileInfo );
  39. $new->important = ' !important';
  40. return $new;
  41. }
  42. }