Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
39 additions
and
14 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
class WebApp_Template { | ||
protected static function _render( $template_name ) { | ||
if( file_exists( 'templates/' . $template_name . '.phtml' ) ) { | ||
ob_start(); | ||
require_once "templates/" . $template_name . ".phtml"; | ||
return ob_get_clean(); | ||
} else { | ||
// fix me | ||
return false; | ||
} | ||
} | ||
|
||
public static function render( $template_name, $use_layout = true, $layout = 'default' ) { | ||
if( $use_layout ) { | ||
|
||
$layout_path = 'templates/layouts/' . $layout . '.phtml'; | ||
|
||
if( !file_exists( $layout_path ) ) { | ||
return false; | ||
} | ||
|
||
$data = self::_render( $template_name ); | ||
$content_for_layout = $data; | ||
|
||
# clean up some things before rendering the view | ||
unset( $data ); | ||
|
||
include( $layout_path); | ||
|
||
} else { | ||
$data = self::_render( $template_name ); | ||
echo $data; | ||
} | ||
} | ||
} |