/** * Render informer html-code reserved for page URL * Use cache * * @param $url * @return string */ public function render($url) { $data = $this->getData($url); if (!empty($data['informer_id'])) { $engine = new TemplateEngine(); $cacheKey = 'compiled_' . $data['informer_id']; $compiled = $this->cache->get($cacheKey); if (!$compiled) { $template = $this->getTemplate($data['informer_id']); if (empty($template['error']) && !empty($template['code']) && !empty($template['items']) && isset($template['replace'])) { $compiled = $engine->compileWithItems($template['code'], $template['items'], $template['replace']); } $this->cache->set($cacheKey, $compiled); } return $engine->render($compiled, $data['params']); } else { return ''; } }