Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- Class TemplateLoader {
- public static function compile($filePath, $variables = array())
- {
- $output = NULL;
- if(file_exists($filePath)){
- // Extract the variables to a local namespace
- extract($variables);
- // Start output buffering
- ob_start();
- // Include the template file
- include $filePath;
- // End buffering and return its contents
- $output = ob_get_clean();
- }
- return $output;
- }
- public static function render($filePath, $variables = array())
- {
- echo self::compile($filePath, $variables);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement