You are here

public static function JSONText::preRenderText in JSON Field 8

Pre-render callback: Renders a JSON text element into #markup.

@todo Add JSON formatting libraries.

File

src/Element/JSONText.php, line 33

Class

JSONText
Provides a JSON text render element.

Namespace

Drupal\json_field\Element

Code

public static function preRenderText($element) {

  // Create the render array.
  $markup_element = [
    '#markup' => new FormattableMarkup('<pre><code>@json</code></pre>', [
      '@json' => JsonMarkup::create($element['#text']),
    ]),
  ];
  return $markup_element;
}