You are here

function template_preprocess_name_item in Name Field 8

Prepares variables for name_item template.

Default template: name-item.html.twig.

Parameters

array $variables: An associative array containing:

  • item: Keyed array of name components.
  • format: The machine name of the format.
  • settings: Additional settings to control the parser.

File

./name.theme.inc, line 21
Theme functions for name module.

Code

function template_preprocess_name_item(array &$variables) {
  $variables['settings'] += [
    'markup' => 0,
  ];
  $format = name_get_format_by_machine_name($variables['format']);
  if (empty($format)) {
    $format = name_get_format_by_machine_name('default');
  }
  $variables['formatted_name'] = \Drupal::service('name.format_parser')
    ->parse($variables['item'], $format, $variables['settings']);
}