<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Nette Framework forum : Development of Nette Framework : RFC – Request for Comments : Latte: higher abstraction for Application\UI</title>
<link>https://forum.nette.org/en</link>
<description>Nette Framework forum</description>
<language>en</language>
<docs>http://backend.userland.com/rss</docs>
<item>
	<title>Latte: higher abstraction for Application\UI (RFC – Request for Comments)</title>
	<dc:creator>David Grudl</dc:creator>
	<link>https://forum.nette.org/en/18895#p130031</link>
	<guid isPermaLink="false">130031@http://forum.nette.org/en</guid>
	<description>&lt;p&gt;Done in v2.2&lt;/p&gt;
</description>
	<pubDate>Wed, 30 Apr 2014 14:54:01 +0200</pubDate>
</item>
<item>
	<title>Latte: higher abstraction for Application\UI (RFC – Request for Comments)</title>
	<dc:creator>David Grudl</dc:creator>
	<link>https://forum.nette.org/en/18895#p130030</link>
	<guid isPermaLink="false">130030@http://forum.nette.org/en</guid>
	<description>&lt;p&gt;(This builds upon the &lt;a
href=&quot;https://forum.nette.org/en/18894-latte-redesign-that-could-easily-be-used-standalone&quot;&gt;previous
RFC&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Firstly, the Nette\Templating***Template becomes very humble
&lt;code&gt;Nette\Application\UI\Template&lt;/code&gt; and will be used internally by
Control (in fact for backward compatibility, or like abstraction for different
templating engines):&lt;/p&gt;

&lt;pre
class=&quot;language-php&quot;&gt;&lt;code&gt;class Template
{
	private $engine, $file, $params;

	function __get() // for $params
	function __set()

	function setFile($file) { // for compatiblity
		$this-&amp;gt;file = $file;
	}

	function registerHelper(...) { // for compatiblity
		$this-&amp;gt;latte-&amp;gt;addModifier(...);
	}

	function render($file = NULL) {
		$this-&amp;gt;engine-&amp;gt;render($file ?: $this-&amp;gt;file, $this-&amp;gt;params);
	}
}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Secondly, Template will be created by
&lt;code&gt;Application\UI\TemplateFactory&lt;/code&gt;, which will configure Latte for
Application\UI (it means: appends UI&apos;s and form&apos;s macros, sets HTML\XHTML mode
and all required parameters like &lt;code&gt;_presenter&lt;/code&gt; or
&lt;code&gt;$basePath&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;TemplateFactory, as service, will be passed via DI to presenters.&lt;/p&gt;

&lt;p&gt;All controls will use the presenter&apos;s TemplateFactory by default:&lt;/p&gt;

&lt;pre
class=&quot;language-php&quot;&gt;&lt;code&gt;abstract class Control extends PresenterComponent implements IRenderable
{
	protected function createTemplate()
	{
		return $this-&amp;gt;getTemplateFactory()-&amp;gt;create($this);
	}&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;When a control will need add or reconfigure some macros, it can overwrite
&lt;code&gt;createTemplate&lt;/code&gt; or add them in &lt;code&gt;render()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;When a control will need use different Latte factory, it overwrites
&lt;code&gt;getTemplateFactory()&lt;/code&gt; (and returns different factory, which receives
via constructor etc.).&lt;/p&gt;

&lt;p&gt;NOTE! You can pass custom Template factory to Presenter too. &lt;strong&gt;But no
control shall rely on this customization.&lt;/strong&gt; All controls must be
renderable with the default factory OR must overwrite
&lt;code&gt;getTemplateFactory&lt;/code&gt; and use its own factory.&lt;/p&gt;
</description>
	<pubDate>Thu, 13 Feb 2014 00:11:24 +0100</pubDate>
</item>
</channel>
</rss>
