You are here

public function LessEngineLess_php::compile in Less CSS Preprocessor 7.4

Same name and namespace in other branches
  1. 8 engines/engine.less_php.inc \LessEngineLess_php::compile()

This compiles using engine specific function calls.

Overrides LessEngineInterface::compile

File

engines/engine.less_php.inc, line 31

Class

LessEngineLess_php
Class \LessEngineLess_php

Code

public function compile() {
  $compiled_styles = NULL;
  try {
    if ($this->source_maps_enabled) {
      $this->less_php_parser
        ->SetOption('sourceMap', $this->source_maps_enabled);
      $this->less_php_parser
        ->SetOption('sourceMapBasepath', $this->source_maps_base_path);
      $this->less_php_parser
        ->SetOption('sourceMapRootpath', $this->source_maps_root_path);
    }

    // Less.js does not allow path aliasing. Set aliases to blank for consistency.
    $this->less_php_parser
      ->SetImportDirs(array_fill_keys($this->import_directories, ''));
    $this->less_php_parser
      ->parseFile($this->input_file_path);
    $this->less_php_parser
      ->ModifyVars($this->variables);
    $compiled_styles = $this->less_php_parser
      ->getCss();
    $this->dependencies = $this->less_php_parser
      ->AllParsedFiles();
  } catch (Exception $e) {
    throw $e;
  }
  return $compiled_styles;
}