original_string: protected function create_navigation(\stdClass $tree) {
          if ($this->firstelement) {
              $html = \html_writer::start_tag('ul', ['class' => 'treeview parent block_tree list', 'id' => 'my-tree']);
              $this->firstelement = false;
          } else {
              $html = \html_writer::start_tag('ul', ['class' => 'parent', 'role' => 'group']);
          }
          foreach ($tree->children as $child) {
              if (isset($child->children)) {
                  $html .= \html_writer::start_tag('li', ['class' => 'menu-item', 'role' => 'treeitem', 'aria-expanded' => 'false']);
                  $html .= $child->name;
                  $html .= $this->create_navigation($child);
              } else {
                  $html .= \html_writer::start_tag('li', ['class' => 'item', 'role' => 'treeitem', 'aria-expanded' => 'false']);
                  // Normal display.
                  if (isset($child->datavar)) {
                      $html .= \html_writer::link('#', $child->name, ['data-var' => $child->datavar]);
                  } else {
                      $html .= \html_writer::link($child->url, $child->name, ['target' => '_blank']);
                  }
              }
              $html .= \html_writer::end_tag('li');
          }
          $html .= \html_writer::end_tag('ul');
          return $html;
      }
code: protected function create_navigation(\stdClass $tree) {
          if ($this->firstelement) {
              $html = \html_writer::start_tag('ul', ['class' => 'treeview parent block_tree list', 'id' => 'my-tree']);
              $this->firstelement = false;
          } else {
              $html = \html_writer::start_tag('ul', ['class' => 'parent', 'role' => 'group']);
          }
          foreach ($tree->children as $child) {
              if (isset($child->children)) {
                  $html .= \html_writer::start_tag('li', ['class' => 'menu-item', 'role' => 'treeitem', 'aria-expanded' => 'false']);
                  $html .= $child->name;
                  $html .= $this->create_navigation($child);
              } else {
                  $html .= \html_writer::start_tag('li', ['class' => 'item', 'role' => 'treeitem', 'aria-expanded' => 'false']);
                  // Normal display.
                  if (isset($child->datavar)) {
                      $html .= \html_writer::link('#', $child->name, ['data-var' => $child->datavar]);
                  } else {
                      $html .= \html_writer::link($child->url, $child->name, ['target' => '_blank']);
                  }
              }
              $html .= \html_writer::end_tag('li');
          }
          $html .= \html_writer::end_tag('ul');
          return $html;
      }
code_tokens: protected function create_navigation ( \ stdClass $ tree ) { if ( $ this -> firstelement ) { $ html = \ html_writer :: start_tag ( 'ul' , [ 'class' => 'treeview parent block_tree list' , 'id' => 'my-tree' ] ) ; $ this -> firstelement = false ; } else { $ html = \ html_writer :: start_tag ( 'ul' , [ 'class' => 'parent' , 'role' => 'group' ] ) ; } foreach ( $ tree -> children as $ child ) { if ( isset ( $ child -> children ) ) { $ html .= \ html_writer :: start_tag ( 'li' , [ 'class' => 'menu-item' , 'role' => 'treeitem' , 'aria-expanded' => 'false' ] ) ; $ html .= $ child -> name ; $ html .= $ this -> create_navigation ( $ child ) ; } else { $ html .= \ html_writer :: start_tag ( 'li' , [ 'class' => 'item' , 'role' => 'treeitem' , 'aria-expanded' => 'false' ] ) ; // Normal display. if ( isset ( $ child -> datavar ) ) { $ html .= \ html_writer :: link ( '#' , $ child -> name , [ 'data-var' => $ child -> datavar ] ) ; } else { $ html .= \ html_writer :: link ( $ child -> url , $ child -> name , [ 'target' => '_blank' ] ) ; } } $ html .= \ html_writer :: end_tag ( 'li' ) ; } $ html .= \ html_writer :: end_tag ( 'ul' ) ; return $ html ; }
docstring: Creates the navigation list html. Why this and not a template? My attempts at trying to get a recursive template
  working failed.
  
  @param  \stdClass $tree Full tree to create navigation out of.
  @return string navigation html.
docstring_tokens: Creates the navigation list html . Why this and not a template? My attempts at trying to get a recursive template working failed .