You are here

protected function MinifyHTMLExit::minifyhtmlPlaceholderCallbackStyle in Minify Source HTML 8

Helper function to add place holder for <style> tag.

Parameters

array $matches: Matches from initial preg_replace().

Return value

string The placeholder string.

File

src/EventSubscriber/MinifyHTMLExit.php, line 276

Class

MinifyHTMLExit
Minifies the HTML of the response.

Namespace

Drupal\minifyhtml\EventSubscriber

Code

protected function minifyhtmlPlaceholderCallbackStyle(array $matches) {
  $search = [];
  $replace = [];

  // Only strip multi-line comments in <style> if required.
  if ($this->config
    ->get('minifyhtml.config')
    ->get('strip_comments')) {
    $search[] = '!/\\*.*?\\*/!s';
    $replace[] = '';
  }

  // Trim each line.
  $search[] = '/^\\s+|\\s+$/m';
  $replace[] = '';
  $style = preg_replace($search, $replace, $matches[0]);
  return $this
    ->minifyPlaceholderReplace(trim($style));
}