diff --git a/TODO b/TODO index 4653cf9..c84c8dc 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,8 @@ # TODO # +- testing and documenting autorendering features - adding an option('display_errors'); by default ini_set('display_errors', 0) in production env, but enabled if env is dev (unless matching option is enabled) - explain autoload_controller() in README -- doc before($route) - in debug output, formating debug_backtrace to be me readable (like debug_backtrace output but with extra informations that can be toggled) - #36, explicit HTTP/1.1 - adding tests with special characters for request_uri diff --git a/examples/example04/index.php b/examples/example04/index.php new file mode 100644 index 0000000..2854977 --- /dev/null +++ b/examples/example04/index.php @@ -0,0 +1,32 @@ +example 01: Hello World!
  • example 02: errors
  • example 03: routes with options, and conditional before function
  • +
  • example 04: autorendering example
  • Url Rewriting with Limonade.
  • diff --git a/lib/limonade.php b/lib/limonade.php index 4eafe76..f44431b 100644 --- a/lib/limonade.php +++ b/lib/limonade.php @@ -329,6 +329,7 @@ function run($env = null) option('session', LIM_SESSION_NAME); // true, false or the name of your session option('encoding', 'utf-8'); option('gzip', false); + option('autorender', false); option('x-sendfile', 0); // 0: disabled, // X-SENDFILE: for Apache and Lighttpd v. >= 1.5, // X-LIGHTTPD-SEND-FILE: for Apache and Lighttpd v. < 1.5 @@ -405,10 +406,9 @@ function autoload_controller($callback) call_if_exists('before', $route); # 6.4 Call matching controller function and output result - if($output = call_user_func_array($route['function'], array_values($route['params']))) - { - echo after(error_notices_render() . $output, $route); - } + $output = call_user_func_array($route['function'], array_values($route['params'])); + if(is_null($output) && option('autorender')) $output = call_if_exists('autorender', $route); + echo after(error_notices_render() . $output, $route); } else halt(SERVER_ERROR, "Routing error: undefined function '{$route['function']}'", $route); }