コード例 #1
0
ファイル: Import.php プロジェクト: poef/ariadne
 /**
  * @see ILess_Node
  */
 public function compile(ILess_Environment $env, $arguments = null, $important = null)
 {
     if ($this->skip) {
         return array();
     }
     if ($this->getOption('inline')) {
         // FIXME: this section is marked as "todo" in less.js project
         // see: lib/less/tree/import.js
         // original comment: todo needs to reference css file not import
         // $this->root is string here!
         $contents = new ILess_Node_Anonymous($this->root, 0, new ILess_FileInfo(array('filename' => $this->importedFilename)), true);
         return $this->features ? new ILess_Node_Media(array($contents), $this->features->value) : array($contents);
     } elseif ($this->css) {
         $features = $this->features ? $this->features->compile($env) : null;
         $import = new ILess_Node_Import($this->compilePath($env), $features, $this->options, $this->index);
         if (!$import->css && $import->hasError()) {
             throw $import->getError();
         }
         return $import;
     } else {
         $ruleset = new ILess_Node_Ruleset(array(), $this->root ? $this->root->rules : array());
         $ruleset->compileImports($env);
         return $this->features ? new ILess_Node_Media($ruleset->rules, $this->features->value) : $ruleset->rules;
     }
 }
コード例 #2
0
ファイル: Condition.php プロジェクト: poef/ariadne
 /**
  * Compiles the node
  *
  * @param ILess_Environment $env
  * @return boolean
  */
 public function compile(ILess_Environment $env, $arguments = null, $important = null)
 {
     $a = $this->lvalue->compile($env);
     $b = $this->rvalue->compile($env);
     switch ($this->op) {
         case 'and':
             $result = $a && $b;
             break;
         case 'or':
             $result = $a || $b;
             break;
         default:
             if (self::methodExists($a, 'compare')) {
                 $result = $a->compare($b);
             } elseif (self::methodExists($b, 'compare')) {
                 $result = $b->compare($a);
             } else {
                 throw new ILess_Exception_Compiler('Unable to perform the comparison', $this->index, $env->currentFileInfo);
             }
             // FIXME: Operators has beed modified. its seems that there is a bug in less.js
             // The operator "=>" is missing in case 0 and case 1
             // Less.js version:
             /*
                             switch (result) {
                case -1: return op === '<' || op === '=<' || op === '<=';
                case  0: return op === '=' || op === '>=' || op === '=<' || op === '<=';
                case  1: return op === '>' || op === '>=';
                             }
             */
             switch ($result) {
                 case -1:
                     $result = $this->op === '<' || $this->op === '=<' || $this->op === '<=';
                     break;
                 case 0:
                     $result = $this->op === '=' || $this->op === '>=' || $this->op === '=>' || $this->op === '=<' || $this->op === '<=';
                     break;
                 case 1:
                     $result = $this->op === '>' || $this->op === '>=' || $this->op === '=>';
                     break;
             }
             break;
     }
     return $this->negate ? !$result : $result;
 }
コード例 #3
0
ファイル: Attribute.php プロジェクト: poef/ariadne
 /**
  * Compiles the node
  *
  * @param ILess_Environment $env
  * @return ILess_Node_Attribute
  */
 public function compile(ILess_Environment $env, $arguments = null, $important = null)
 {
     return new ILess_Node_Attribute(self::methodExists($this->key, 'compile') ? $this->key->compile($env) : $this->key, $this->operator, self::methodExists($this->value, 'compile') ? $this->value->compile($env) : $this->value);
 }