original_string: protected function _renderOptgroup($label, $optgroup, $disabled, $selected, $templateVars, $escape)
      {
          $opts = $optgroup;
          $attrs = [];
          if (isset($optgroup['options'], $optgroup['text'])) {
              $opts = $optgroup['options'];
              $label = $optgroup['text'];
              $attrs = $optgroup;
          }
          $groupOptions = $this->_renderOptions($opts, $disabled, $selected, $templateVars, $escape);
  
          return $this->_templates->format('optgroup', [
              'label' => $escape ? h($label) : $label,
              'content' => implode('', $groupOptions),
              'templateVars' => $templateVars,
              'attrs' => $this->_templates->formatAttributes($attrs, ['text', 'options']),
          ]);
      }
code: protected function _renderOptgroup($label, $optgroup, $disabled, $selected, $templateVars, $escape)
      {
          $opts = $optgroup;
          $attrs = [];
          if (isset($optgroup['options'], $optgroup['text'])) {
              $opts = $optgroup['options'];
              $label = $optgroup['text'];
              $attrs = $optgroup;
          }
          $groupOptions = $this->_renderOptions($opts, $disabled, $selected, $templateVars, $escape);
  
          return $this->_templates->format('optgroup', [
              'label' => $escape ? h($label) : $label,
              'content' => implode('', $groupOptions),
              'templateVars' => $templateVars,
              'attrs' => $this->_templates->formatAttributes($attrs, ['text', 'options']),
          ]);
      }
code_tokens: protected function _renderOptgroup ( $ label , $ optgroup , $ disabled , $ selected , $ templateVars , $ escape ) { $ opts = $ optgroup ; $ attrs = [ ] ; if ( isset ( $ optgroup [ 'options' ] , $ optgroup [ 'text' ] ) ) { $ opts = $ optgroup [ 'options' ] ; $ label = $ optgroup [ 'text' ] ; $ attrs = $ optgroup ; } $ groupOptions = $ this -> _renderOptions ( $ opts , $ disabled , $ selected , $ templateVars , $ escape ) ; return $ this -> _templates -> format ( 'optgroup' , [ 'label' => $ escape ? h ( $ label ) : $ label , 'content' => implode ( '' , $ groupOptions ) , 'templateVars' => $ templateVars , 'attrs' => $ this -> _templates -> formatAttributes ( $ attrs , [ 'text' , 'options' ] ) , ] ) ; }
docstring: Render the contents of an optgroup element.
  
  @param string $label The optgroup label text
  @param array $optgroup The opt group data.
  @param array|null $disabled The options to disable.
  @param array|string|null $selected The options to select.
  @param array $templateVars Additional template variables.
  @param bool $escape Toggle HTML escaping
  @return string Formatted template string
docstring_tokens: Render the contents of an optgroup element .