Name: Password: Want to register?

API Documentation

[Parent dir]

Information about libs/Template.php

Classes

Code

1<?php
2class Template{
3    //static private $path2function = array();
4    
This function allows to include a template and pass it some parameters without polluting caller's namespace. (2009.02.03 17:32)[update][delete]
5 static function show($path, $arg = NULL){ 6 $path = "templates/$path.php"; 7 /* 8 if (!isset(self::$path2function[$path])) { 9 $code = file_get_contents($path); 10 $name = create_function('$arg', "?>$code<?php "); 11 if (!$name) { 12 throw new Exception("Could not compile template '$path'"); 13 } 14 self::$path2function[$path] = $name; 15 } 16 $name = self::$path2function[$path]; 17 $name($arg); 18 */ 19 include $path; 20 } 21 22 static function get($path, $info = array()){ 23 ob_start(); 24 self::show($path, $info); 25 $block = ob_get_contents(); 26 ob_end_clean(); 27 return $block; 28 } 29 30 static function exists($path){ 31 return file_exists("templates/$path.php"); 32 } 33}
[download]
Made with Notepad++ Also on SourceForge.net