BigPipeStrategy::createBigPipeNoJsPlaceholder

protected static BigPipeStrategy::createBigPipeNoJsPlaceholder($original_placeholder, array $placeholder_render_array, $placeholder_must_be_attribute_safe = FALSE)

Creates a BigPipe no-JS placeholder.

Parameters

string $original_placeholder: The original placeholder.

array $placeholder_render_array: The render array for a placeholder.

bool $placeholder_must_be_attribute_safe: Whether the placeholder must be safe for use in a HTML attribute (in case it's a placeholder for a HTML attribute value or a subset of it).

Return value

array The resulting BigPipe no-JS placeholder render array.

File

core/modules/big_pipe/src/Render/Placeholder/BigPipeStrategy.php, line 222

Class

BigPipeStrategy
Defines the BigPipe placeholder strategy, to send HTML in chunks.

Namespace

Drupal\big_pipe\Render\Placeholder

Code

protected static function createBigPipeNoJsPlaceholder($original_placeholder, array $placeholder_render_array, $placeholder_must_be_attribute_safe = FALSE) {
  if (!$placeholder_must_be_attribute_safe) {
    $big_pipe_placeholder = '<div data-big-pipe-nojs-placeholder-id="' . Html::escape(static::generateBigPipePlaceholderId($original_placeholder, $placeholder_render_array)) . '"></div>';
  }
  else {
    $big_pipe_placeholder = 'big_pipe_nojs_placeholder_attribute_safe:' . Html::escape($original_placeholder);
  }

  return [
    '#markup' => $big_pipe_placeholder,
    '#cache' => [
      'max-age' => 0,
      'contexts' => [
        'session.exists',
      ],
    ],
    '#attached' => [
      'big_pipe_nojs_placeholders' => [
        $big_pipe_placeholder => $placeholder_render_array,
      ],
    ],
  ];
}
doc_Drupal
2016-10-29 08:46:20
Comments
Leave a Comment

Please login to continue.