You are here

class LessEngineLess_js in Less CSS Preprocessor 7.4

Same name and namespace in other branches
  1. 8 engines/engine.less_js.inc \LessEngineLess_js

Class \LessEngineLess_js

Hierarchy

Expanded class hierarchy of LessEngineLess_js

1 string reference to 'LessEngineLess_js'
less_less_engines in ./less.module
Implements hook_less_engines().

File

engines/engine.less_js.inc, line 6

View source
class LessEngineLess_js extends LessEngine {

  /**
   * @var \Lessjs
   */
  private $less_js_parser;

  /**
   * Instantiates new instances of \Lessjs.
   *
   * @param string $input_file_path
   *
   * @see \Lessjs
   */
  public function __construct($input_file_path) {
    parent::__construct($input_file_path);
    $this->less_js_parser = Lessjs::create($this->input_file_path);
  }

  /**
   * We override here because getting dependencies from less.js requires another
   * full parse. This way we only do that if dependencies are requested.
   *
   * @return string[]
   *
   * @see \Lessjs::depends()
   */
  public function getDependencies() {
    $this->dependencies = $this->less_js_parser
      ->depends();
    return parent::getDependencies();
  }

  /**
   * {@inheritdoc}
   * This compiles using engine specific function calls.
   */
  public function compile() {
    $compiled_styles = NULL;
    try {
      $this->less_js_parser
        ->source_maps($this->source_maps_enabled, $this->source_maps_base_path, $this->source_maps_root_path);
      foreach ($this->import_directories as $directory) {
        $this->less_js_parser
          ->include_path($directory);
      }
      foreach ($this->variables as $var_name => $var_value) {
        $this->less_js_parser
          ->modify_var(trim($var_name, '@'), trim($var_value, ';'));
      }
      $compiled_styles = $this->less_js_parser
        ->compile();
    } catch (Exception $e) {
      throw $e;
    }
    return $compiled_styles;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LessEngine::$dependencies protected property This will get populated with a list of files that $input_file_path depended on through @import statements.
LessEngine::$import_directories protected property List of directories that are to be used for @import lookups.
LessEngine::$input_file_path protected property Path to the input .less file.
LessEngine::$source_maps_base_path protected property
LessEngine::$source_maps_enabled protected property Flag if source maps are enabled.
LessEngine::$source_maps_root_path protected property
LessEngine::$variables protected property This contains any variables that are to be modified into the output.
LessEngine::modifyVariables public function Set/override variables. Overrides LessEngineInterface::modifyVariables
LessEngine::setImportDirectories public function Set list of lookup directories for @import statements. Overrides LessEngineInterface::setImportDirectories
LessEngine::setSourceMaps public function Enable Overrides LessEngineInterface::setSourceMaps
LessEngineLess_js::$less_js_parser private property
LessEngineLess_js::compile public function This compiles using engine specific function calls. Overrides LessEngineInterface::compile
LessEngineLess_js::getDependencies public function We override here because getting dependencies from less.js requires another full parse. This way we only do that if dependencies are requested. Overrides LessEngine::getDependencies
LessEngineLess_js::__construct public function Instantiates new instances of \Lessjs. Overrides LessEngine::__construct