mirror of
https://github.com/moodle/moodle.git
synced 2025-08-11 11:56:40 +02:00
MDL-44357 theme: Allow core to compile LESS in PHP
This commit is contained in:
parent
9b8555fbea
commit
d433cf37cd
68 changed files with 10947 additions and 47 deletions
54
lib/lessphp/Tree/Attribute.php
Normal file
54
lib/lessphp/Tree/Attribute.php
Normal file
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Attribute
|
||||
*
|
||||
* @package Less
|
||||
* @subpackage tree
|
||||
*/
|
||||
class Less_Tree_Attribute extends Less_Tree{
|
||||
|
||||
public $key;
|
||||
public $op;
|
||||
public $value;
|
||||
public $type = 'Attribute';
|
||||
|
||||
function __construct($key, $op, $value){
|
||||
$this->key = $key;
|
||||
$this->op = $op;
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
function compile($env){
|
||||
|
||||
$key_obj = is_object($this->key);
|
||||
$val_obj = is_object($this->value);
|
||||
|
||||
if( !$key_obj && !$val_obj ){
|
||||
return $this;
|
||||
}
|
||||
|
||||
return new Less_Tree_Attribute(
|
||||
$key_obj ? $this->key->compile($env) : $this->key ,
|
||||
$this->op,
|
||||
$val_obj ? $this->value->compile($env) : $this->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Less_Tree::genCSS
|
||||
*/
|
||||
function genCSS( $output ){
|
||||
$output->add( $this->toCSS() );
|
||||
}
|
||||
|
||||
function toCSS(){
|
||||
$value = $this->key;
|
||||
|
||||
if( $this->op ){
|
||||
$value .= $this->op;
|
||||
$value .= (is_object($this->value) ? $this->value->toCSS() : $this->value);
|
||||
}
|
||||
|
||||
return '[' . $value . ']';
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue