You are here

function template_preprocess_yamlform_codemirror in YAML Form 8

Prepares variables for form CodeMirror template.

Default template: yamlform-codemirror.html.twig.

Parameters

array $variables: An associative array containing the following key:

  • code: The code.
  • type: The type of code.

File

includes/yamlform.theme.inc, line 414
Preprocessors and helper functions to make theming easier.

Code

function template_preprocess_yamlform_codemirror(array &$variables) {
  $variables['mode'] = YamlFormCodeMirror::getMode($variables['type']);
  if (is_string($variables['code'])) {
    $variables['code'] = [
      '#markup' => $variables['code'],
      '#allowed_tags' => Xss::getAdminTagList(),
    ];
  }
}