title: Simple template in PHP / Output buffering performance
body: <p>I'm using in my script very simple template engine:</p>
  
  <pre><code>&lt;?php
  require_once('some_class.php');
  $some_class = new some_class();
  
  function view($file, $vars) {
      ob_start();
      extract($vars);
      include dirname(__FILE__) . '/' . $file . '.php';
      $buffer = ob_get_contents();
      ob_end_clean();
      return $buffer;
  }
  
  echo view('template', array(
      'content' =&gt; some_class::content(),
      'pages' =&gt; some_class::pages(),
      'meta_title' =&gt; some_class::$meta_title,
      'meta_description' =&gt; some_class::$meta_description
  ));
  ?&gt;
  </code></pre>
  
  <p>It worked well but my script grows bigger and i'm adding new functions and sometimes in some situations it take a lot time to load page. My webpage need to use external API sometime and there are delays. How can i rebuild this to work without output buffering?</p>