Exemplo n.º 1
0
 /**
  * @param string $in    Filename without path or extension.
  * @return bool         True if the output file was saved.
  */
 public function compileFile($in)
 {
     $gantry = Gantry::instance();
     /** @var UniformResourceLocator $locator */
     $locator = $gantry['locator'];
     $out = $this->getCssUrl($in);
     $path = $locator->findResource($out, true, true);
     $paths = $locator->mergeResources($this->paths);
     // Set the lookup paths.
     $this->compiler->setBasePath($path);
     $this->compiler->setImportDir($paths);
     $this->compiler->setFormatter('lessjs');
     // Run the compiler.
     $this->compiler->setVariables($this->getVariables());
     $css = $this->compiler->compileFile($in . '.less"');
     $file = File::instance($path);
     // Attempt to lock the file for writing.
     $file->lock(false);
     //TODO: Better way to handle double writing files at same time.
     if ($file->locked() === false) {
         // File was already locked by another process.
         return false;
     }
     $file->save($css);
     $file->unlock();
     $this->createMeta($out, md5($css));
     return true;
 }
Exemplo n.º 2
0
 /**
  * Constructor.
  */
 public function __construct()
 {
     parent::__construct();
     $this->compiler = new Compiler();
     if ($this->production) {
         $this->compiler->setFormatter('lessjs');
     } else {
         $this->compiler->setFormatter('compressed');
         $this->compiler->setPreserveComments(true);
     }
 }