Created
August 3, 2011 18:06
-
-
Save jhbabon/1123346 to your computer and use it in GitHub Desktop.
Quick and dirty PHP function to render templates
This file contains 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 | |
function render($template, $params = array(), $directory = 'templates') { | |
// make sure that the template has the desired params | |
extract($params); | |
// catch the template content | |
ob_start(); | |
include($directory . '/' . $template . '.php'); // you have the correct include_path, right? | |
$applied_template = ob_get_contents(); | |
ob_end_clean(); | |
return $applied_template; | |
} // END function render |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment