From b3cda72e93fff3a4c3476e9e7e78ef2b2a3f02b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 11 Jul 2014 17:06:51 +0200 Subject: PicoFarad framework for routing --- inc/3rdparty/PicoFarad/Template.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 inc/3rdparty/PicoFarad/Template.php (limited to 'inc/3rdparty/PicoFarad/Template.php') diff --git a/inc/3rdparty/PicoFarad/Template.php b/inc/3rdparty/PicoFarad/Template.php new file mode 100644 index 00000000..c32be309 --- /dev/null +++ b/inc/3rdparty/PicoFarad/Template.php @@ -0,0 +1,36 @@ + 'value']); +function load() +{ + if (func_num_args() < 1 || func_num_args() > 2) { + die('Invalid template arguments'); + } + + if (! file_exists(PATH.func_get_arg(0).'.php')) { + die('Unable to load the template: "'.func_get_arg(0).'"'); + } + + if (func_num_args() === 2) { + + if (! is_array(func_get_arg(1))) { + die('Template variables must be an array'); + } + + extract(func_get_arg(1)); + } + + ob_start(); + include PATH.func_get_arg(0).'.php'; + return ob_get_clean(); +} + + +function layout($template_name, array $template_args = array(), $layout_name = 'layout') +{ + return load($layout_name, $template_args + array('content_for_layout' => load($template_name, $template_args))); +} -- cgit v1.2.3