Created
June 4, 2014 07:14
-
-
Save imvision/9136a1bdb32be9cc8f5b to your computer and use it in GitHub Desktop.
PHP Micro Templating
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* PHP Micro Templating | |
*/ | |
namespace imvision; | |
class Template { | |
public static function Render($tmpl, $data = array()) { | |
extract($data); | |
ob_start(); | |
if(file_exists($tmpl)) { | |
include $tmpl; | |
} | |
return ob_get_clean(); | |
} | |
} | |
//Example usage | |
/* | |
include 'tmpl.php'; | |
echo \imvision\Template::Render("content.html"); | |
echo \imvision\Template::Render("content.html", $data_array); | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment