Commit 383233fb authored by Peter Gerken's avatar Peter Gerken Committed by Mateu Aguiló Bosch
Browse files

Issue #3322979 by fisherman90, e0ipso: UTF-8 Umlauts in YML files break on rendering

parent 15628a1f
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@

namespace Drupal\cl_components\Element;

use Drupal\Component\Serialization\Json;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Render\BubbleableMetadata;
@@ -111,9 +110,15 @@ class ComponentElement extends RenderElement {
    if (is_callable($context_alter_callback)) {
      $context = call_user_func($context_alter_callback, $context, $bubbleable_metadata);
    }
    try {
      $serialized_context = json_encode($context, JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
    }
    catch (\JsonException $e) {
      $serialized_context = '';
    }
    $template .= empty($context)
      ? sprintf('{%% embed \'%s\' %%}', $embed_id)
      : sprintf('{%% embed \'%s\' with %s %%}', $embed_id, Json::encode($context));
      : sprintf('{%% embed \'%s\' with %s %%}', $embed_id, $serialized_context);
    $template .= PHP_EOL;
    foreach ($twig_blocks as $block_name => $block_value) {
      $bl_val = is_callable($blocks_alter_callback)