You are here

protected function Container::compactSnippet in GoogleTagManager 8

Returns the compacted snippet.

Parameters

string $snippet: The JavaScript snippet.

array $search: The array of strings to replace with blank.

Return value

string The compacted snippet.

3 calls to Container::compactSnippet()
Container::dataLayerSnippet in src/Entity/Container.php
Returns JavaScript data layer snippet or adds items to data layer.
Container::noscriptSnippet in src/Entity/Container.php
Returns JavaScript noscript snippet.
Container::scriptSnippet in src/Entity/Container.php
Returns JavaScript script snippet.

File

src/Entity/Container.php, line 380

Class

Container
Defines the container configuration entity.

Namespace

Drupal\google_tag\Entity

Code

protected function compactSnippet($snippet, array $search = [
  "\n",
  '  ',
]) {
  $compact = \Drupal::config('google_tag.settings')
    ->get('compact_snippet');
  return $compact ? str_replace($search, '', $snippet) : $snippet;
}