Commits

Anonymous committed dff9fb1

Added comments in preparation for making PWPTemplate available to the public.

Comments (0)

Files changed (3)

 <?php
 /**
- * PWPTemplate version 0.3 06/11/2010
  * Inspired by the basic template class at http://www.massassi.com/php/articles/template_engines/
  *
  * Requires PHP 5
  *
- * @author James Sumners
+ * PWPTemplate is a very simple templating class. It supports arbitrary variable
+ * assignment and caching. The templates can include references to other
+ * instances of PWPTemplate objects. See the example scripts included with the
+ * class for further detail.
+ *
+ * @author James Sumners <james.sumners@gmail.com>
  * @copyright Platypus Web Productions (http://platypuswp.com/)
+ * @license http://opensource.org/licenses/mit-license.php MIT License
+ *
+ * @version 0.3 06/11/2010
  *
  * @package PWPTemplate
  */
 	private $pwp_cached = FALSE;
 	
 	/**
-	*	Sets the file name of the template file.
-	*	@param string
-	*/
-	/**
 	 * Executed when the PWPTemplate object is created. It is pretty silly to
 	 * create the object without supplying a template file.
 	 * 
 	}
 
 }
-
 ?>

cache_example.php

 <?php
 require_once('PWPTemplate.php');
 
+// Create a new PWPTemplate object using the named template.
 $tpl = new PWPTemplate('templates/index.tpl.php');
 
+// Check to see if the template has already been compiled.
+// If the template has been compiled, and the expiration time has not elapsed,
+// we simply need to display what was already done.
 if ($tpl->isCached()) {
 	$tpl->display();
 	return;
 }
 
+// Tell the PWPTemplate object that we wish to cache the output.
 $tpl->enableCache('index');
 
+// Define the $title variable in our template.
 $tpl->set('title', 'This is an example');
 
+// Load a second PWPTemplate object to act as the body of the output page.
 $bodyTpl = new PWPTemplate('templates/index_body.tpl.php');
 
 $content = htmlentities(file_get_contents('http://example.com/'));
+// Assign the value of $content to the $bodyText variable in the body template.
 $bodyTpl->set('bodyText', $content);
 
+// Assign the $body variable in our index template object.
 $tpl->set('body', $bodyTpl);
 
+// Finally, compile the index template and show it to the user.
 $tpl->display();
 ?>
 <?php
 require_once('PWPTemplate.php');
 
+// Create a new PWPTemplate object using the named template.
 $tpl = new PWPTemplate('templates/index.tpl.php');
 
+// Define the $title variable in our template.
 $tpl->set('title', 'This is an example');
 
+// Load a second PWPTemplate object to act as the body of the output page.
 $bodyTpl = new PWPTemplate('templates/index_body.tpl.php');
 
 $content = htmlentities(file_get_contents('http://example.com/'));
+// Assign the value of $content to the $bodyText variable in the body template.
 $bodyTpl->set('bodyText', $content);
 
+// Assign the $body variable in our index template object.
 $tpl->set('body', $bodyTpl);
 
+// Finally, compile the index template and show it to the user.
 $tpl->display();
 ?>