protected function MinifyHTMLExit::minifyhtmlPlaceholderCallbackScript in Minify Source HTML 8
Helper function to add place holder for <script> tag.
Parameters
array $matches: Matches from initial preg_replace().
Return value
string The placeholder string.
File
- src/
EventSubscriber/ MinifyHTMLExit.php, line 244
Class
- MinifyHTMLExit
- Minifies the HTML of the response.
Namespace
Drupal\minifyhtml\EventSubscriberCode
protected function minifyhtmlPlaceholderCallbackScript(array $matches) {
$search = [];
$replace = [];
// Only strip multi-line comments in <script> if required.
if ($this->config
->get('minifyhtml.config')
->get('strip_comments')) {
$search[] = '!/\\*.*?\\*/!s';
$replace[] = '';
}
// Trim each line.
$search[] = '/^\\s+|\\s+$/m';
$replace[] = "\n";
// Remove multiple empty line.
$search[] = '/\\n(\\s*\\n)+/';
$replace[] = "\n";
$script = preg_replace($search, $replace, $matches[0]);
return $this
->minifyPlaceholderReplace(trim($script));
}