/** * @see Engine::render() for documentation and usage */ public function render($template) { wfProfileIn(__METHOD__); $path = $this->prefix == '' ? $template : $this->prefix . DIRECTORY_SEPARATOR . $template; wfProfileIn(__METHOD__ . " - template: {$path}"); $contents = \MustacheService::getInstance()->render($path, $this->values); wfProfileOut(__METHOD__ . " - template: {$path}"); wfProfileOut(__METHOD__); return $contents; }
public function getShareIcons() { $requestlang = $this->getVal('lang'); $title = $this->getVal('title'); $url = $this->getVal('url'); $lang = PageShareHelper::getLangForPageShare($requestlang); $renderedSocialIcons = \MustacheService::getInstance()->render(__DIR__ . '/templates/PageShare_index.mustache', ['services' => $this->prepareShareServicesData($lang, $title, $url)]); $this->setVal('socialIcons', $renderedSocialIcons); $this->response->setCacheValidity(WikiaResponse::CACHE_STANDARD); }
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; } }
public function setUp() { parent::setUp(); $this->file = __DIR__ . '/../templates/test.mustache'; $this->service = MustacheService::getInstance(); }
/** * Render Share dropdown * @return string * @throws Exception */ private function renderShareActions() { /** * Use Mustache render and not renderView because template is outside of extension's * directory and we want to show that explicitly; it's also a bit faster than doing * callback just for render small Mustache template anyway. */ return \MustacheService::getInstance()->render('resources/wikia/ui_components/dropdown_navigation/templates/dropdown.mustache', $this->shareActionsData()); }
/** * Setup method for Insights_loopNotification.mustache template */ public function loopNotification() { $subpage = $this->request->getVal('insight', null); if (InsightsHelper::isInsightPage($subpage)) { $model = InsightsHelper::getInsightModel($subpage); if ($model instanceof InsightsModel) { $params = []; $type = ''; $isFixed = false; $articleName = $this->getVal('article', null); $title = Title::newFromText($articleName); $next = $model->getNextItem($model->getInsightType(), $articleName); $isEdit = $this->request->getBool('isEdit', false); if (!$isEdit) { $isFixed = $model->isItemFixed($title); if ($isFixed) { $model->updateInsightsCache($title->getArticleId()); } } if ($isEdit) { $params = $this->getInProgressNotificationParams($subpage); $type = self::FLOW_STATUS_INPROGRESS; } elseif (!$isFixed) { $params = $this->getNotFixedNotificationParams($subpage, $title, $model); $type = self::FLOW_STATUS_NOTFIXED; } elseif ($isFixed && empty($next)) { $params = $this->getCongratulationsNotificationParams($subpage); $type = self::FLOW_STATUS_ALLDONE; } elseif ($isFixed) { $params = $this->getInsightFixedNotificationParams($subpage, $next); $type = self::FLOW_STATUS_FIXED; } $html = \MustacheService::getInstance()->render('extensions/wikia/Insights/templates/Insights_loopNotification.mustache', $params); $this->response->setData(['html' => $html, 'isFixed' => $isFixed, 'notificationType' => $type]); } } }