/** * Render the template * * @return String */ public function render() { if ($this->getFormat() == self::FORMAT_JSON) { // RENDER AS JSON $this->unassign("_"); //@deprecated _app.* in favor of _.* $this->unassign("_app"); return json_encode($this->getAssigned()); } else { // RENDER AS HTML // Content already rendered if ($this->renderedContent && $this->isRendered) { return $this->renderedContent; } // _.title if (isset($this->meta["title"])) { $this->assign_("title", $this->meta["title"]); } // _.flash_message $flashMessage = $this->getFlashMessage(); if ($flashMessage) { $this->assign_("flash_message", $flashMessage); //@deprecated for naming convetion. Use flash_message $this->assign_("flashMessage", $flashMessage); $this->clearFlashMessage(); } // _.error if ($this->hasError()) { $this->assign_("error", $this->getMessage("error")); } // _.* $this->assign_(["year" => date("Y"), "site_url" => $this->controller->getSiteUrl(), "base_url" => $this->controller->getBaseUrl(), "meta" => $this->meta, "shared_assets" => $this->getPublicAssetsDir(), "assets" => $this->getModuleAssetsDir(), "module_name" => $this->controller->getModuleName(), "module_url" => $this->controller->getModuleUrl(), "controller_name" => $this->controller->getControllerName(), "controller_url" => $this->controller->getControllerUrl(), "action_name" => $this->controller->getActionName(), "action_url" => $this->controller->getActionUrl(), "request_params" => $this->controller->getParams()]); $renderName = $this->templateKeys["view"]; $this->addTemplate($this->templateKeys["view"], $this->actionView, $this->isActionViewAbsolute); if ($this->layout) { $renderName = $this->templateKeys["layout"]; $this->addTemplate($this->templateKeys["layout"], $this->layout, $this->isLayoutAbsolute); } $this->isRendered = true; $this->parse(); if (isset($this->templates[$renderName])) { $this->renderedContent = $this->engine->render($this->templates[$renderName], $this->getAssigned()); // Strip HTML Comments if ($this->controller->getConfig("views.stripHtmlComments")) { $this->renderedContent = Helpers::stripHtmlComments($this->renderedContent); } } return $this->renderedContent; } }