code: protected function renderAttribute($attribute, $index)
      {
          if (is_string($this->template)) {
              $captionOptions = Html::renderTagAttributes(ArrayHelper::getValue($attribute, 'captionOptions', []));
              $contentOptions = Html::renderTagAttributes(ArrayHelper::getValue($attribute, 'contentOptions', []));
              return strtr($this->template, [
                  '{label}' => $attribute['label'],
                  '{value}' => $this->formatter->format($attribute['value'], $attribute['format']),
                  '{captionOptions}' => $captionOptions,
                  '{contentOptions}' => $contentOptions,
              ]);
          }
  
          return call_user_func($this->template, $attribute, $index, $this);
      }
docs: Renders a single attribute.
  @param array $attribute the specification of the attribute to be rendered.
  @param int $index the zero-based index of the attribute in the [[attributes]] array
  @return string the rendering result