latte renderToString jak vypsat latte do hloubky
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.

- regiss
 - Člen | 61
 
V Presenteru
		$content = 'hello <strong>world</strong> <BR/>  {$test|noescape}';
		$template = $this->templateFactory->createTemplate($this);
		$template->test = 'Chci aby se vypsalo {$bar}';
		$template->bar = '<strong>na baru</strong>';
		$latte = $template->getLatte();
		$latte->setLoader(new \Latte\Loaders\StringLoader);
		$html = $latte->renderToString($content, $template->getParameters());
		echo $html;
Vypise:
hello **world**
Chci aby se vypsalo {$bar}
A ja bych potreboval aby se vypsalo „Chci aby se vypsalo na baru“

- Jan Tvrdík
 - Nette guru | 2595
 
- Je to blbost, nechtěj to.
 - Můžeš si definovat vlastní filter, který to prožene přes
	
renderToString. 

- regiss
 - Člen | 61
 
Dekuji za odpoved. Pridal jsem latte filter, ted uz vsechno funguje. Da se kod napsat lepe?
		$content = 'hello <strong>world</strong> <BR/>  {$test|filterBar|noescape}';
		$template = $this->templateFactory->createTemplate($this);
		$template->test = 'Chci aby se vypsalo {$bar|noescape}';
		$latte = $template->getLatte();
		$latte->addFilter('filterBar', function ($s) {
			$template = $this->templateFactory->createTemplate($this);
			$template->bar = '<strong>na baru</strong>';
			$latte = $template->getLatte();
			$html = $latte->renderToString($s, $template->getParameters());
			return $html;
		});
		$latte->setLoader(new \Latte\Loaders\StringLoader);
		$html = $latte->renderToString($content, $template->getParameters());