You are here

function minifyhtml_placeholder_callback_script in Minify Source HTML 7

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

Parameters

array $matches: Matches from initial preg_replace().

Return value

string The placeholder string.

File

./minifyhtml.module, line 276
Hook and helper functions for the Minify HTML module.

Code

function minifyhtml_placeholder_callback_script(array $matches) {
  $search = array();
  $replace = array();

  // Only strip multi-line comments in <script> if required.
  if (variable_get('minifyhtml_strip_comments', TRUE)) {
    $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 minifyhtml_placeholder_replace(trim($script));
}