/** * @see Engine::render() for documentation and usage */ public function render($template) { wfProfileIn(__METHOD__); $dir = $this->prefix == '' ? '' : $this->prefix . DIRECTORY_SEPARATOR; $path = $dir . $template; wfProfileIn(__METHOD__ . " - template: {$path}"); $contents = \HandlebarsService::getInstance()->render($path, $this->values); wfProfileOut(__METHOD__ . " - template: {$path}"); wfProfileOut(__METHOD__); return $contents; }
protected function renderHtml() { wfProfileIn(__METHOD__); $this->buildTemplatePath($this->response->getControllerName(), $this->response->getMethodName()); $data = $this->response->getData(); switch ($this->response->getTemplateEngine()) { case WikiaResponse::TEMPLATE_ENGINE_HANDLEBARS: $handlebarsService = HandlebarsService::getInstance(); $result = $handlebarsService->render($this->getTemplatePath(), $data); wfProfileOut(__METHOD__); return $result; break; case WikiaResponse::TEMPLATE_ENGINE_MUSTACHE: $m = MustacheService::getInstance(); $result = $m->render($this->getTemplatePath(), $data); wfProfileOut(__METHOD__); return $result; break; case WikiaResponse::TEMPLATE_ENGINE_PHP: default: // Export the app wg and wf helper objects into the template // Note: never do this for Raw or Json formats due to major security issues there $data['app'] = F::app(); $data['wg'] = F::app()->wg; $data['wf'] = F::app()->wf; if (!empty($data)) { extract($data); } ob_start(); $templatePath = $this->getTemplatePath(); wfProfileIn(__METHOD__ . ' - template: ' . $templatePath); require $templatePath; wfProfileOut(__METHOD__ . ' - template: ' . $templatePath); $out = ob_get_clean(); wfProfileOut(__METHOD__); return $out; break; } }