Skip to content

Instantly share code, notes, and snippets.

@jhbabon
Created August 3, 2011 18:06
Show Gist options
  • Save jhbabon/1123346 to your computer and use it in GitHub Desktop.
Save jhbabon/1123346 to your computer and use it in GitHub Desktop.
Quick and dirty PHP function to render templates
<?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