From 082227f1cdd29c50af51fa132b539e3471bbfbaa Mon, 21 May 2018 21:06:00 +0200 From: hass Date: Mon, 21 May 2018 21:05:52 +0200 Subject: [PATCH] Issue #2821815 by mxh: How to add JavaScript to html_head without it being escaped? diff --git a/google_analytics.module b/google_analytics.module index addd4ec..509bd66 100644 --- a/google_analytics.module +++ b/google_analytics.module @@ -15,6 +15,7 @@ use Drupal\Component\Utility\Unicode; use Drupal\Core\Cache\Cache; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Render\Markup; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Site\Settings; use Drupal\Core\Url; @@ -352,7 +353,7 @@ $page['#attached']['html_head'][] = [ [ '#tag' => 'script', - '#value' => new GoogleAnalyticsJavaScriptSnippet($script), + '#value' => Markup::create($script), ], 'google_analytics_tracking_script', ];