1 token.inc token_render_array(array $array, array $options = array())

Renders a render array for display as a token.

Parameters

array $array: The render array to be converted to HTML.

array $options: Array of options for rendering. Values can include:

  • sanitize: Runs check_plain() on the rendered output.
  • join: Joins rendered items together with a comma.

Return value

string: HTML of rendered item.

See also

token_render_array_value()

File

core/includes/token.inc, line 831
Backdrop placeholder/token replacement system.

Code

function token_render_array(array $array, array $options = array()) {
  $rendered = array();
  foreach ($array as $key => $value) {
    if (substr($key, 0, 1) === '#') {
      continue;
    }
    $rendered[] = is_array($value) ? render($value) : (string) $value;
  }
  if (!empty($options['sanitize'])) {
    $rendered = array_map('check_plain', $rendered);
  }
  $join = isset($options['join']) ? $options['join'] : ', ';
  return implode($join, $rendered);
}