Beispiel #1
0
 public function compile($env = null)
 {
     $args = array();
     foreach ($this->args as $a) {
         $args[] = $a->compile($env);
     }
     $nameLC = strtolower($this->name);
     switch ($nameLC) {
         case '%':
             $nameLC = '_percent';
             break;
         case 'get-unit':
             $nameLC = 'getunit';
             break;
         case 'data-uri':
             $nameLC = 'datauri';
             break;
         case 'svg-gradient':
             $nameLC = 'svggradient';
             break;
     }
     $result = null;
     if ($nameLC === 'default') {
         $result = Less_Tree_DefaultFunc::compile();
     } else {
         if (method_exists('Less_Functions', $nameLC)) {
             // 1.
             try {
                 $func = new Less_Functions($env, $this->currentFileInfo);
                 $result = call_user_func_array(array($func, $nameLC), $args);
             } catch (Exception $e) {
                 throw new Less_Exception_Compiler('error evaluating function `' . $this->name . '` ' . $e->getMessage() . ' index: ' . $this->index);
             }
         } elseif (isset($env->functions[$nameLC]) && is_callable($env->functions[$nameLC])) {
             try {
                 $result = call_user_func_array($env->functions[$nameLC], $args);
             } catch (Exception $e) {
                 throw new Less_Exception_Compiler('error evaluating function `' . $this->name . '` ' . $e->getMessage() . ' index: ' . $this->index);
             }
         }
     }
     if ($result !== null) {
         return $result;
     }
     return new Less_Tree_Call($this->name, $args, $this->index, $this->currentFileInfo);
 }
Beispiel #2
0
 public function compile($env = null)
 {
     $args = array();
     foreach ($this->args as $a) {
         $args[] = $a->compile($env);
     }
     $name = $this->name;
     switch ($name) {
         case '%':
             $name = '_percent';
             break;
         case 'data-uri':
             $name = 'datauri';
             break;
         case 'svg-gradient':
             $name = 'svggradient';
             break;
         case 'default':
             return Less_Tree_DefaultFunc::compile();
     }
     //echo '<h4>'.$name.'</h4>';
     if (method_exists('Less_Functions', $name)) {
         // 1.
         try {
             $func = new Less_Functions($env, $this->currentFileInfo);
             $result = call_user_func_array(array($func, $name), $args);
             if ($result != null) {
                 return $result;
             }
         } catch (Exception $e) {
             throw new Less_Exception_Compiler('error evaluating function `' . $this->name . '` ' . $e->getMessage() . ' index: ' . $this->index);
         }
     }
     return new Less_Tree_Call($this->name, $args, $this->index, $this->currentFileInfo);
 }