public function __construct(CacheProvider $cache, Config $config) { $this->cache = $cache; $this->latte = new Engine(); $parser = $this->latte->getParser(); $parser->defaultSyntax = $config->default_syntax; $this->latte->setTempDirectory($cache->config->temp_dir); }
protected function getLatteEngine() { if (!isset($this->latteEngine)) { $this->latteEngine = new Engine(); $this->latteEngine->setTempDirectory($this->tempDir); } return $this->latteEngine; }
/** * @param string $basePath * @param string $tempPath */ public function __construct($basePath, $tempPath = null) { $this->latte = new Engine(); $this->latte->setLoader(new FileLoader()); if ($tempPath) { $this->latte->setTempDirectory($tempPath); } $this->basePath = $basePath; }
/** * The transformer constructor. * * Options are: * - "latte" a \Latte\Engine instance * - "tmp-dir" the temporary directory where Latte will store compiled templates * if the option "latte" is provided, option "tmp-dir" is ignored. * * @param array $options The LatteTransformer options */ public function __construct(array $options = array()) { $this->stringLoader = new StringLoader(); if (array_key_exists('latte', $options)) { $this->latte = $options['latte']; } else { $this->latte = new Engine(); if (array_key_exists('temp-dir', $options)) { $this->latte->setTempDirectory($options['temp-dir']); } } }
/** * @return Engine */ function latte() { $latte = new Engine(); $latte->setLoader(filter('latte.loader', new FileLoader())); $latte->setTempDirectory(\dir\cache()); $latte->addFilter('md', '\\cms\\md'); trigger('latte.macroset', new MacroSet($latte->getCompiler())); return filter('latte', $latte); }
/** * @return Engine */ function latte() { $latte = new Engine(); $latte->setLoader(filter(FileLoader::class, new FileLoader())); $latte->setTempDirectory(\dir\cache()); $latte->addFilter('md', '\\cms\\md'); trigger(MacroSet::class, new MacroSet($latte->getCompiler())); return filter(Engine::class, $latte); }
public function render($viewFile, $data, $return = false) { $latte = new Engine(); $latte->setTempDirectory('runtime'); if ($return) { return $latte->renderToString($viewFile, $data); } else { return $latte->render($viewFile, $data); } }
/** * Register the application services. * * @return void */ public function register() { $this->app->singleton('latte.engine', function ($app) { $latte = new Latte\Engine(); $latte->setTempDirectory($app['config']['view.compiled']); return $latte; }); $this->app->singleton('latte.globals', function ($app) { return new LatteGlobals(); }); $this->app->bind('view', function ($app) { return new LatteFactory($app); }); }
/** * Setting templating system. * @return Engine */ private function createLatteEngine() { // Create directory. $temp = $this->temp . '/_Latte.TemplateCache'; if (!is_dir($temp)) { FileSystem::createDir($temp); } $latte = new Engine(); $latte->setTempDirectory($temp); // Macro for forms. $latte->onCompile[] = function ($latte) { FormMacros::install($latte->getCompiler()); }; return $latte; }
/** * {@inheritdoc} */ public function register(ContainerInterface $app) { $app->closure(Engine::class, function () { $engine = new Engine(); $engine->setLoader(new FileLoader()); $cachePath = config('view.cache'); if ($cachePath) { $engine->setTempDirectory(path($cachePath)); } return $engine; }); $app->closure(RenderInterface::class, function ($app) { return new LatteView($app[Engine::class], path(config('view.path'))); }); }
/** * Register the application services. * * @return void * @throws \InvalidArgumentException */ public function register() { $this->app->singleton('latte.engine', function ($app) { $latte = new Latte\Engine(); $latte->setAutoRefresh($app['config']['app.debug']); $latte->setTempDirectory($app['config']['view.compiled']); return $latte; }); $this->app->resolving('view', function (Factory $viewFactory, Application $app) { if ($viewFactory instanceof \Illuminate\View\Factory) { $viewFactory->addExtension('latte', 'latte', function () use($app) { return new LatteEngineBridge($app['latte.engine']); }); } else { throw new \InvalidArgumentException('Can\'t register Latte\\Engine, ' . get_class($viewFactory) . ' view factory is not supported.'); } }); }
/** * @return Engine */ public function create() { $engine = new Engine(); // Options $engine->setTempDirectory($this->tempDir); $engine->setAutoRefresh($this->autoRefresh); $engine->setContentType($this->contentType); // Filters foreach ($this->filters as $name => $callback) { $engine->addFilter($name, $callback); } // Macros $engine->onCompile[] = function (Engine $engine) { $compiler = $engine->getCompiler(); foreach ($this->macros as $macro) { $macro::install($compiler); } }; return $engine; }
/** * @return Latte\Engine */ private function getLatte() { if (!isset($this->latte)) { $this->latte = new Latte\Engine(); $this->latte->setTempDirectory($this->tempDir); $this->latte->setAutoRefresh(FALSE); $this->latte->onCompile[] = function (Latte\Engine $latte) { $set = new Latte\Macros\MacroSet($latte->getCompiler()); $set->addMacro('link', 'echo %escape(call_user_func($getLink, %node.word, %node.array))'); }; $this->latte->addFilter('attachmentLabel', function (MimePart $attachment) { $contentDisposition = $attachment->getHeader('Content-Disposition'); $contentType = $attachment->getHeader('Content-Type'); $matches = Strings::match($contentDisposition, '#filename="(.+?)"#'); return ($matches ? "{$matches['1']} " : '') . "({$contentType})"; }); $this->latte->addFilter('plainText', function (MimePart $part) { $ref = new \ReflectionProperty('Nette\\Mail\\MimePart', 'parts'); $ref->setAccessible(TRUE); $queue = array($part); for ($i = 0; $i < count($queue); $i++) { /** @var MimePart $subPart */ foreach ($ref->getValue($queue[$i]) as $subPart) { $contentType = $subPart->getHeader('Content-Type'); if (Strings::startsWith($contentType, 'text/plain') && $subPart->getHeader('Content-Transfer-Encoding') !== 'base64') { // Take first available plain text return (string) $subPart->getBody(); } elseif (Strings::startsWith($contentType, 'multipart/alternative')) { $queue[] = $subPart; } } } return $part->getBody(); }); } return $this->latte; }
protected function createLatte() { $latte = new Latte\Engine(); foreach ($this->helpers as $key => $callback) { $latte->addFilter($key, $callback); } foreach ($this->helperLoaders as $callback) { $latte->addFilter(NULL, function ($name) use($callback, $latte) { if ($res = call_user_func($callback, $name)) { $latte->addFilter($name, $res); } }); } if ($this->cacheStorage instanceof Nette\Caching\Storages\PhpFileStorage) { $latte->setTempDirectory($this->cacheStorage->getDir()); } return $latte; }
public function setTempDirectory($tempDir) { self::$engine->setTempDirectory($tempDir); }
function createLatte() { $latte = new Engine(); $latte->setTempDirectory(ROOT_DIR . "/temp"); return $latte; }
/** * @return Engine */ function createLatte() { $latte = new Engine(); $latte->setTempDirectory($this->config['latte']['tempDir']); return $latte; }