Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

The world's simplest (decent) PHP templating engine... (See related posts)

...is PHP, so why not use it?
   1  
   2  function include_view($__view, $vars=NULL) {
   3      # Start buffering the generated text.
   4      ob_start();
   5  
   6      # Process the view.
   7      if (!is_null($vars)) {
   8          extract($vars, EXTR_OVERWRITE | EXTR_REFS);
   9      }
  10      include("views/$__view.php");
  11  
  12      # Grab the generated content and clean up.
  13      $content = ob_get_contents();
  14      ob_end_clean();
  15  
  16      return $content;
  17  }

Comments on this post

joshduck posts on Sep 17, 2005 at 03:30
I've used a more complex version of this on a large community website. It works really well. Definately recommended.

You need to create an account or log in to post comments to this site.


Click here to browse all 5502 code snippets

Related Posts