示例#1
0
 /**
  * Generates the CSS
  *
  * @return string
  */
 public function generateCSS()
 {
     $output = new Less_Output_Mapped($this->contentsMap, $this);
     // catch the output
     $this->root->genCSS($output);
     $sourceMapUrl = $this->getOption('sourceMapURL');
     $sourceMapFilename = $this->getOption('sourceMapFilename');
     $sourceMapContent = $this->generateJson();
     $sourceMapWriteTo = $this->getOption('sourceMapWriteTo');
     if (!$sourceMapUrl && $sourceMapFilename) {
         $sourceMapUrl = $this->normalizeFilename($sourceMapFilename);
     }
     // write map to a file
     if ($sourceMapWriteTo) {
         $this->saveMap($sourceMapWriteTo, $sourceMapContent);
     }
     // inline the map
     if (!$sourceMapUrl) {
         $sourceMapUrl = sprintf('data:application/json,%s', Less_Functions::encodeURIComponent($sourceMapContent));
     }
     if ($sourceMapUrl) {
         $output->add(sprintf('/*# sourceMappingURL=%s */', $sourceMapUrl));
     }
     return $output->toString();
 }