PHPR / Smarty templates

Smarty Templates have been around for a while now and are pretty popular with developers.  One of the things that I really like about PHPR (PHPRUNNER) is that it utilizes Smarty Templates and stores them in a directory called <templates> inside of whatever application you are working in.  Let’s say we are working on a list page, with Smarty in use there are actually two separate files in play, one file will be called list.php and it will look something like this:

   1: include('Smarty.class.php');
   2:  
   3: // create object
   4: $smarty = new Smarty;
   5:  
   6: // assign some content. This would typically come from
   7: // a database or other source, but we'll use static
   8: // values for the purpose of this example.
   9: $smarty->assign('name', 'george smith');
  10: $smarty->assign('address', '45th & Harris');
  11:  
  12: // display it
  13: $smarty->display('list.htm');

As you can see, the list.php page just contains your actual PHP Code itself.  The second file in this equation is located inside of the <templates> directory and is called list.htm.  It contains the html and css values for the page:

   1: <html>
   2: <head>
   3: <title>User Info</title>
   4: </head>
   5: <body>
   6:  
   7: User Information:<p>
   8:  
   9: Name: {$name}<br>
  10: Address: {$address}<br>
  11:  
  12: </body>
  13: </html>

PHPRunner manual – Smarty templates