original_string: function _prepareTemplate($name, $label, $required, $error)
      {
          if (is_array($label)) {
              $nameLabel = array_shift($label);
          } else {
              $nameLabel = $label;
          }
          if (isset($this->_templates[$name])) {
              $html = str_replace('{label}', $nameLabel, $this->_templates[$name]);
          } else {
              $html = str_replace('{label}', $nameLabel, $this->_elementTemplate);
          }
          if ($required) {
              $html = str_replace('<!-- BEGIN required -->', '', $html);
              $html = str_replace('<!-- END required -->', '', $html);
          } else {
              $html = preg_replace("/([ \t\n\r]*)?<!-- BEGIN required -->(\s|\S)*<!-- END required -->([ \t\n\r]*)?/iU", '', $html);
          }
          if (isset($error)) {
              $html = str_replace('{error}', $error, $html);
              $html = str_replace('<!-- BEGIN error -->', '', $html);
              $html = str_replace('<!-- END error -->', '', $html);
          } else {
              $html = preg_replace("/([ \t\n\r]*)?<!-- BEGIN error -->(\s|\S)*<!-- END error -->([ \t\n\r]*)?/iU", '', $html);
          }
          if (is_array($label)) {
              foreach($label as $key => $text) {
                  $key  = is_int($key)? $key + 2: $key;
                  $html = str_replace("{label_{$key}}", $text, $html);
                  $html = str_replace("<!-- BEGIN label_{$key} -->", '', $html);
                  $html = str_replace("<!-- END label_{$key} -->", '', $html);
              }
          }
          if (strpos($html, '{label_')) {
              $html = preg_replace('/\s*<!-- BEGIN label_(\S+) -->.*<!-- END label_\1 -->\s*/i', '', $html);
          }
          return $html;
      }
code: function _prepareTemplate($name, $label, $required, $error)
      {
          if (is_array($label)) {
              $nameLabel = array_shift($label);
          } else {
              $nameLabel = $label;
          }
          if (isset($this->_templates[$name])) {
              $html = str_replace('{label}', $nameLabel, $this->_templates[$name]);
          } else {
              $html = str_replace('{label}', $nameLabel, $this->_elementTemplate);
          }
          if ($required) {
              $html = str_replace('<!-- BEGIN required -->', '', $html);
              $html = str_replace('<!-- END required -->', '', $html);
          } else {
              $html = preg_replace("/([ \t\n\r]*)?<!-- BEGIN required -->(\s|\S)*<!-- END required -->([ \t\n\r]*)?/iU", '', $html);
          }
          if (isset($error)) {
              $html = str_replace('{error}', $error, $html);
              $html = str_replace('<!-- BEGIN error -->', '', $html);
              $html = str_replace('<!-- END error -->', '', $html);
          } else {
              $html = preg_replace("/([ \t\n\r]*)?<!-- BEGIN error -->(\s|\S)*<!-- END error -->([ \t\n\r]*)?/iU", '', $html);
          }
          if (is_array($label)) {
              foreach($label as $key => $text) {
                  $key  = is_int($key)? $key + 2: $key;
                  $html = str_replace("{label_{$key}}", $text, $html);
                  $html = str_replace("<!-- BEGIN label_{$key} -->", '', $html);
                  $html = str_replace("<!-- END label_{$key} -->", '', $html);
              }
          }
          if (strpos($html, '{label_')) {
              $html = preg_replace('/\s*<!-- BEGIN label_(\S+) -->.*<!-- END label_\1 -->\s*/i', '', $html);
          }
          return $html;
      }
code_tokens: function _prepareTemplate ( $ name , $ label , $ required , $ error ) { if ( is_array ( $ label ) ) { $ nameLabel = array_shift ( $ label ) ; } else { $ nameLabel = $ label ; } if ( isset ( $ this -> _templates [ $ name ] ) ) { $ html = str_replace ( '{label}' , $ nameLabel , $ this -> _templates [ $ name ] ) ; } else { $ html = str_replace ( '{label}' , $ nameLabel , $ this -> _elementTemplate ) ; } if ( $ required ) { $ html = str_replace ( '<!-- BEGIN required -->' , '' , $ html ) ; $ html = str_replace ( '<!-- END required -->' , '' , $ html ) ; } else { $ html = preg_replace ( "/([ \t\n\r]*)?<!-- BEGIN required -->(\s|\S)*<!-- END required -->([ \t\n\r]*)?/iU" , '' , $ html ) ; } if ( isset ( $ error ) ) { $ html = str_replace ( '{error}' , $ error , $ html ) ; $ html = str_replace ( '<!-- BEGIN error -->' , '' , $ html ) ; $ html = str_replace ( '<!-- END error -->' , '' , $ html ) ; } else { $ html = preg_replace ( "/([ \t\n\r]*)?<!-- BEGIN error -->(\s|\S)*<!-- END error -->([ \t\n\r]*)?/iU" , '' , $ html ) ; } if ( is_array ( $ label ) ) { foreach ( $ label as $ key => $ text ) { $ key = is_int ( $ key ) ? $ key + 2 : $ key ; $ html = str_replace ( "{label_{$key}}" , $ text , $ html ) ; $ html = str_replace ( "<!-- BEGIN label_{$key} -->" , '' , $ html ) ; $ html = str_replace ( "<!-- END label_{$key} -->" , '' , $ html ) ; } } if ( strpos ( $ html , '{label_' ) ) { $ html = preg_replace ( '/\s*<!-- BEGIN label_(\S+) -->.*<!-- END label_\1 -->\s*/i' , '' , $ html ) ; } return $ html ; }
docstring: Helper method for renderElement
  
  @param    string      Element name
  @param    mixed       Element label (if using an array of labels, you should set the appropriate template)
  @param    bool        Whether an element is required
  @param    string      Error message associated with the element
  @access   private
  @see      renderElement()
  @return   string      Html for element
docstring_tokens: Helper method for renderElement