original_string: public function setRegion($region, $item)
      {
          if (is_array($item)) {
              $template = array_shift($item);
              $data = $item ? reset($item) : array();
              $content = $this->render($template, $data);
          } else {
              $content = trim($item);
          }
  
          if ($content !== '' && isset($this->templates["region_$region"])) {
  
              $weight = 1;
  
              if (isset($this->data["region_$region"])) {
                  $weight = count($this->data["region_$region"]) + 1;
              }
  
              $this->data["region_$region"][] = array('rendered' => $content, 'weight' => $weight);
          }
      }
code: public function setRegion($region, $item)
      {
          if (is_array($item)) {
              $template = array_shift($item);
              $data = $item ? reset($item) : array();
              $content = $this->render($template, $data);
          } else {
              $content = trim($item);
          }
  
          if ($content !== '' && isset($this->templates["region_$region"])) {
  
              $weight = 1;
  
              if (isset($this->data["region_$region"])) {
                  $weight = count($this->data["region_$region"]) + 1;
              }
  
              $this->data["region_$region"][] = array('rendered' => $content, 'weight' => $weight);
          }
      }
code_tokens: public function setRegion ( $ region , $ item ) { if ( is_array ( $ item ) ) { $ template = array_shift ( $ item ) ; $ data = $ item ? reset ( $ item ) : array ( ) ; $ content = $ this -> render ( $ template , $ data ) ; } else { $ content = trim ( $ item ) ; } if ( $ content !== '' && isset ( $ this -> templates [ "region_$region" ] ) ) { $ weight = 1 ; if ( isset ( $ this -> data [ "region_$region" ] ) ) { $ weight = count ( $ this -> data [ "region_$region" ] ) + 1 ; } $ this -> data [ "region_$region" ] [ ] = array ( 'rendered' => $ content , 'weight' => $ weight ) ; } }
docstring: Adds an item to a region
  @param string $region
  @param string|array $item Expected array format:
  first item - template, second - variables for $this->render()
docstring_tokens: Adds an item to a region