Exemplo n.º 1
0
 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_MUSTACHE:
             $m = new Mustache();
             $result = $m->render(file_get_contents($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
             wfProfileIn(__METHOD__ . ' - templateengine PHP');
             $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__ . ' - templateengine PHP');
             wfProfileOut(__METHOD__);
             return $out;
             break;
     }
 }