function render() { if ($this->file == NULL) { throw new InvalidStateException("Template file name was not specified."); } $this->__set('template', $this); $cache = new NCache($storage = $this->getCacheStorage(), 'Nette.FileTemplate'); if ($storage instanceof NTemplateCacheStorage) { $storage->hint = str_replace(dirname(dirname($this->file)), '', $this->file); } $cached = $content = $cache[$this->file]; if ($content === NULL) { try { $content = $this->compile(file_get_contents($this->file)); $content = "<?php\n\n// source file: {$this->file}\n\n?>{$content}"; } catch (NTemplateException $e) { $e->setSourceFile($this->file); throw $e; } $cache->save($this->file, $content, array(NCache::FILES => $this->file, NCache::EXPIRATION => self::$cacheExpire, NCache::CONSTS => 'NFramework::REVISION')); $cache->release(); $cached = $cache[$this->file]; } if ($cached !== NULL && $storage instanceof NTemplateCacheStorage) { NLimitedScope::load($cached['file'], $this->getParams()); fclose($cached['handle']); } else { NLimitedScope::evaluate($content, $this->getParams()); } }
function render() { if ($this->getFile() == NULL) { throw new InvalidStateException("Template file name was not specified."); } $cache = new NCache($storage = $this->getCacheStorage(), 'wplatte'); if ($storage instanceof NPhpFileStorage) { $storage->hint = str_replace(dirname(dirname($this->getFile())), '', $this->getFile()); } $cached = $compiled = $cache->load($this->getFile()); if ($compiled === NULL) { try { $compiled = "<?php\n\n// source file: {$this->getFile()}\n\n?>" . $this->compile(); } catch (NTemplateException $e) { $e->setSourceFile($this->getFile()); throw $e; } $cache->save($this->getFile(), $compiled, array(NCache::FILES => $this->getFile(), NCache::CONSTS => array('NFramework::REVISION', 'WPLATTE_CACHE_VERSION'))); $cache->release(); $cached = $cache->load($this->getFile()); } if ($cached !== NULL && $storage instanceof NPhpFileStorage) { NLimitedScope::load($cached['file'], $this->getParams()); } else { NLimitedScope::evaluate($compiled, $this->getParams()); } }
function render() { if ($this->file == NULL) { throw new InvalidStateException("Template file name was not specified."); } $this->__set('template', $this); $shortName = str_replace(NEnvironment::getVariable('appDir'), '', $this->file); $cache = new NCache($this->getCacheStorage(), 'Nette.Template'); $key = trim(strtr($shortName, '\\/@', '.._'), '.') . '-' . md5($this->file); $cached = $content = $cache[$key]; if ($content === NULL) { if (!$this->getFilters()) { $this->onPrepareFilters($this); } if (!$this->getFilters()) { NLimitedScope::load($this->file, $this->getParams()); return; } $content = $this->compile(file_get_contents($this->file), "file …{$shortName}"); $cache->save($key, $content, array(NCache::FILES => $this->file, NCache::EXPIRE => self::$cacheExpire)); $cache->release(); $cached = $cache[$key]; } if ($cached !== NULL && self::$cacheStorage instanceof NTemplateCacheStorage) { NLimitedScope::load($cached['file'], $this->getParams()); fclose($cached['handle']); } else { NLimitedScope::evaluate($content, $this->getParams()); } }