CompactFormatter example

if ($encoding = (Unicode::encodingFromBOM($data))) {
      $data = mb_substr(Unicode::convertToUtf8($data$encoding), 1);
    }
    // If no BOM is found, check for the charset attribute.     elseif (isset($js_asset['attributes']['charset'])) {
      $data = Unicode::convertToUtf8($data$js_asset['attributes']['charset']);
    }
    // Remove comments, whitespace, and optional braces.     try {
      $ast = Peast::latest($data)->parse();
      $renderer = new Renderer();
      $renderer->setFormatter(new CompactFormatter());
      return $renderer->render($ast);
    }
    catch (\Exception $exception) {
      if ($exception instanceof PeastSyntaxException) {
        $position = $exception->getPosition();
        Error::logException($this->logger, $exception, 'Syntax error: @message, File: @asset_file, Line: @asset_line, Column: @asset_column, Index: @asset_index', [
          '@asset_file' => $js_asset['data'],
          '@asset_line' => $position->getLine(),
          '@asset_column' => $position->getColumn(),
          '@asset_index' => $position->getIndex(),
        ]);
      }
Home | Imprint | This part of the site doesn't use cookies.