<?php require_once "vendor/autoload.php"; use Spore\Spore; $app = new Spore(); $app->get("/", function () { return array("message" => "Hello World from Spore"); }); $app->run();
/** * If a @template annotation has been defined, this function will return the output * of Slim's parsing of a template, if the correct @render annotation has been specified * * @param Route $autoroute * @param \Spore\Spore $app * @param $data * * @return string */ private function getTemplateOutput(Route $autoroute, Spore $app, $data) { $template = $autoroute->getTemplate(); $renderMode = $autoroute->getRender(); $output = ""; switch ($renderMode) { case "always": $app->render($template, $data); $output = ob_get_clean(); break; case "never": return Serializer::getSerializedData($app, $data); break; default: if (!$app->request()->isAjax()) { $app->render($template, $data); $output = ob_get_clean(); } else { return Serializer::getSerializedData($app, $data); } break; } return $output; }