예제 #1
0
파일: Gpeasy.php 프로젝트: jbzoo/less
 /**
  * @return \Less_Parser
  */
 protected function _initCompiler()
 {
     if ($this->_compiler) {
         return $this->_compiler;
     }
     $options = array('compress' => false, 'strictUnits' => false, 'strictMath' => false, 'relativeUrls' => true, 'cache_method' => false, 'sourceMap' => false, 'indentation' => '    ');
     if ($this->_isDebug()) {
         $options['sourceMap'] = true;
         $options['sourceMapRootpath'] = $this->_options->get('root_path');
         $options['sourceMapBasepath'] = $this->_options->get('root_path');
     }
     // Create compilier
     $this->_compiler = new \Less_Parser($options);
     $this->_compiler->Reset();
     // Global depends
     $mixins = $this->_options->get('autoload');
     foreach ($mixins as $mixin) {
         $this->_compiler->parseFile($mixin);
     }
     // Add custom vars
     $this->_compiler->ModifyVars((array) $this->_options->get('global_vars', []));
     // Set paths
     $importPaths = (array) $this->_options->get('import_paths', []);
     foreach ($importPaths as $fullPath => $relPath) {
         $this->setImportPath($fullPath, $relPath);
     }
     // Set cutsom functions
     $functions = (array) $this->_options->get('functions', [], 'arr');
     foreach ($functions as $name => $function) {
         $this->_compiler->registerFunction($name, $function);
     }
     return $this->_compiler;
 }
예제 #2
0
 /**
  * Resets all configurations.
  *
  * @return void
  */
 public function reset()
 {
     $this->compiler->Reset();
 }