<?xml version="1.0" ?>
<rss version="2.0">
	<channel>
		<title>Keith's Weblog: Comments on &quot;Push vs. Pull templating&quot;</title>
		<description>Keith's Weblog: Comments on &quot;Push vs. Pull templating&quot;, posted on June 22, 2004</description>
		<link>http://keithdevens.com/weblog/archive/2004/Jun/22/templating</link>

		<category>Programming</category>
		<language>en-us</language>
		<image>
			<link>http://keithdevens.com/weblog</link>
			<title>Keith Devens .com</title>
			<url>http://keithdevens.com/images/kbd.gif</url>
		</image>

		<item>
			<title>by Selkirk</title>
			<link>http://keithdevens.com/weblog/archive/2004/Jun/22/templating#comment4839</link>
			<guid isPermaLink="false">http://keithdevens.com/weblog/4965#comment4839</guid>
			<pubDate>Wed, 23 Jun 2004 03:01:50 +0000</pubDate>
			<description>&lt;p class=&quot;st-markup&quot;&gt;You may want to take a look at the &lt;a href=&quot;http://wact.sourceforge.net/index.php/TemplateView&quot;&gt;Template View&lt;/a&gt; pattern page for the &lt;a href=&quot;http://wact.sourceforge.net/&quot;&gt;WACT&lt;/a&gt; project.  This page talks about push versus pull templates.  We have added many pull features to WACT.  We have a &amp;quot;predefined property&amp;quot; feature, that lets an application define a property in terms of code that is called only if the property is referenced in the template.  We also encourage assigning iterators and lazy loading objects into the template instead of building arrays up front. There is a link to an article at the bottom of that page that talks about push vs. pull templates and argues that pull templates are bad.&lt;/p&gt;

</description>
		</item>
		<item>
			<title>by Ian Bicking</title>
			<link>http://keithdevens.com/weblog/archive/2004/Jun/22/templating#comment4840</link>
			<guid isPermaLink="false">http://keithdevens.com/weblog/4965#comment4840</guid>
			<pubDate>Wed, 23 Jun 2004 03:50:42 +0000</pubDate>
			<description>&lt;p class=&quot;st-markup&quot;&gt;This all seems to complicate things.  Most templates are pull, in effect, though that depends on the capabilities of the underlying language to some degree.  If you want &amp;quot;pull&amp;quot; in a Python-based template, you typically just need to implement an object with a &lt;em style=&quot;font-style: normal; text-decoration: underline&quot;&gt;_getitem&lt;/em&gt;_ method.  Or in a template with expressions (Cheetah, ZPT, and many others) you just use those expressions to &amp;quot;pull&amp;quot; out values.  Things like caching results can be done, as needed, outside of the template.  There's lots of code out there to do generalized memoizing in Python.&lt;/p&gt;

</description>
		</item>
		<item>
			<title>by Keith</title>
			<link>http://keithdevens.com/weblog/archive/2004/Jun/22/templating#comment4841</link>
			<guid isPermaLink="false">http://keithdevens.com/weblog/4965#comment4841</guid>
			<pubDate>Wed, 23 Jun 2004 03:57:54 +0000</pubDate>
			<description>&lt;p class=&quot;st-markup&quot;&gt;Hey, awesome. I didn't know anyone else had thought of this before. Thanks for the pointers. The page makes a few points that I hadn't thought of, one of them being that the issue with option 2 I outlined above, that &amp;quot;you may wind up caching more data than you actually need for the request&amp;quot;, is a problem that plagues push templating as well.&lt;/p&gt;

&lt;p class=&quot;st-markup&quot;&gt;However, as I'm reading, it appears that the discussions of pull templating aren't covering what I consider to be pull templating. In other words, what I mean by &amp;quot;pull&amp;quot; is different than what they mean by &amp;quot;pull&amp;quot;. The best way I can think to explain the difference is to highlight the difference between &amp;quot;retrieving&amp;quot; and &amp;quot;finding&amp;quot;. The examples of pull templating on the &lt;a href=&quot;http://wact.sourceforge.net/index.php/TemplateView&quot;&gt;TemplateView page&lt;/a&gt; as well as in &lt;a href=&quot;http://www.cs.usfca.edu/~parrt/papers/mvc.templates.pdf&quot;&gt;the PDF linked at the bottom&lt;/a&gt; both have to do with &lt;em&gt;retrieval&lt;/em&gt;, not discovery. As you can see in the example on the TemplateView page:&lt;/p&gt;

&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;
&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;$Page&amp;#160;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&amp;amp;&amp;#160;new&amp;#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;Template&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'/list.html'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$List&amp;#160;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&amp;amp;&amp;#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$Page&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;findChild&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'ExampleList'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$List&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;setDataSet&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;NewRecordSet&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'SELECT&amp;#160;Name,&amp;#160;Description&amp;#160;FROM&amp;#160;phpmodules'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;));&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$Page&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;display&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;();&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;br /&gt;&lt;/span&gt;
&lt;/span&gt;
&lt;/code&gt;&lt;p class=&quot;st-markup&quot;&gt;They're still &lt;em&gt;pushing&lt;/em&gt; the data into the template, it just happens to be retrieved on template execution rather than before. It's still &amp;quot;push&amp;quot; even though the data is a lazily-built iterator rather than a normal array.&lt;/p&gt;

</description>
		</item>
		<item>
			<title>by Keith</title>
			<link>http://keithdevens.com/weblog/archive/2004/Jun/22/templating#comment4842</link>
			<guid isPermaLink="false">http://keithdevens.com/weblog/4965#comment4842</guid>
			<pubDate>Wed, 23 Jun 2004 04:05:11 +0000</pubDate>
			<description>&lt;p class=&quot;st-markup&quot;&gt;Ian, the example with Cheetah you offered is the best example I can think of. As Cheetah's NameMapper goes through the SearchList, it'll request the variable reference in the template from any object in the SearchList. If an object in the list &amp;quot;knows&amp;quot; how to find any data that might be requested, that's the ideal implementation of &amp;quot;pull&amp;quot;. Python, as usual, makes things easy. &lt;img class=&quot;smiley&quot; src=&quot;/images/smiley_side.gif&quot; alt=&quot;Smiley&quot; /&gt;&lt;/p&gt;

&lt;p class=&quot;st-markup&quot;&gt;As I mentioned above, I was planning on implementing pull-style templates this way in Cheetah. I misspoke slightly above, however. I was planning on modifying Cheetah, but I remembered it wasn't to get pull-style templates, because that can be done without modifying Cheetah. I was planning on modifying it and submitting a patch to get rid of the horrible (IMO) errorCatcher implementation.&lt;/p&gt;

</description>
		</item>
		<item>
			<title>by Harry Fuecks</title>
			<link>http://keithdevens.com/weblog/archive/2004/Jun/22/templating#comment4846</link>
			<guid isPermaLink="false">http://keithdevens.com/weblog/4965#comment4846</guid>
			<pubDate>Wed, 23 Jun 2004 12:30:56 +0000</pubDate>
			<description>&lt;p class=&quot;st-markup&quot;&gt;WACT uses a mix of push and pull. For that example you pointed out;&lt;/p&gt;

&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;
&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;$Page&amp;#160;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&amp;amp;&amp;#160;new&amp;#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;Template&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'/list.html'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$List&amp;#160;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;=&amp;amp;&amp;#160;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$Page&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;findChild&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'ExampleList'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$List&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;setDataSet&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;NewRecordSet&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;'SELECT&amp;#160;Name,&amp;#160;Description&amp;#160;FROM&amp;#160;phpmodules'&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;));&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$Page&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;display&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;();&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;br /&gt;&lt;/span&gt;
&lt;/span&gt;
&lt;/code&gt;&lt;p class=&quot;st-markup&quot;&gt;The template 'list.html' might contain something like;&lt;/p&gt;

&lt;code&gt;&lt;span style=&quot;color: #c00&quot;&gt;&amp;lt;&lt;span style=&quot;color: #00c&quot;&gt;body&lt;/span&gt;&lt;span style=&quot;color: #060&quot;&gt;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #c00&quot;&gt;&amp;lt;&lt;span style=&quot;color: #00c&quot;&gt;h1&lt;/span&gt;&lt;span style=&quot;color: #060&quot;&gt;&lt;/span&gt;&amp;gt;&lt;/span&gt;The&amp;#160;results...&lt;span style=&quot;color: #c00&quot;&gt;&amp;lt;&lt;span style=&quot;color: #00c&quot;&gt;/h1&lt;/span&gt;&lt;span style=&quot;color: #060&quot;&gt;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;list:LIST&amp;#160;id='ExampleList'&amp;gt;&lt;br /&gt;
&amp;#160;&amp;#160;&lt;span style=&quot;color: #c00&quot;&gt;&amp;lt;&lt;span style=&quot;color: #00c&quot;&gt;ul&lt;/span&gt;&lt;span style=&quot;color: #060&quot;&gt;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;lt;list:ITEM&amp;gt;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style=&quot;color: #c00&quot;&gt;&amp;lt;&lt;span style=&quot;color: #00c&quot;&gt;li&lt;/span&gt;&lt;span style=&quot;color: #060&quot;&gt;&lt;/span&gt;&amp;gt;&lt;/span&gt;{$Name}:&amp;#160;{$Description}&lt;span style=&quot;color: #c00&quot;&gt;&amp;lt;&lt;span style=&quot;color: #00c&quot;&gt;/li&lt;/span&gt;&lt;span style=&quot;color: #060&quot;&gt;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;lt;/list:ITEM&amp;gt;&lt;br /&gt;
&amp;#160;&amp;#160;&lt;span style=&quot;color: #c00&quot;&gt;&amp;lt;&lt;span style=&quot;color: #00c&quot;&gt;/ul&lt;/span&gt;&lt;span style=&quot;color: #060&quot;&gt;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;lt;/list:LIST&amp;gt;&lt;br /&gt;
&lt;/code&gt;

&lt;p class=&quot;st-markup&quot;&gt;In other words in PHP you push a dataset to the template without identifying what the template should do with the variables contained in the dataset.&lt;/p&gt;

&lt;p class=&quot;st-markup&quot;&gt;It's in the template itself you name the variables you want to pull out of the dataset for display.&lt;/p&gt;

&lt;p class=&quot;st-markup&quot;&gt;WACT recently got a more advanced &amp;quot;data binding&amp;quot; (i.e. pull) language for the templates - more than just {$varname}. It's described a little &lt;a href=&quot;http://wact.sourceforge.net/index.php/TemplateAuthorsGuide&quot;&gt;here&lt;/a&gt;.  This is getting applied in some of the &amp;quot;datatable*&amp;quot; templates &lt;a href=&quot;http://cvs.sourceforge.net/viewcvs.py/wact/wact/examples/apps/demoapp/templates/source/&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p class=&quot;st-markup&quot;&gt;Enough already.&lt;/p&gt;

</description>
		</item>
		<item>
			<title>by Clayton Scott</title>
			<link>http://keithdevens.com/weblog/archive/2004/Jun/22/templating#comment4853</link>
			<guid isPermaLink="false">http://keithdevens.com/weblog/4965#comment4853</guid>
			<pubDate>Thu, 24 Jun 2004 04:54:55 +0000</pubDate>
			<description>&lt;p class=&quot;st-markup&quot;&gt;I think that Template::Toolkit=http://template-toolkit.org/ for Perl is a &amp;quot;Pull Template&amp;quot; according to your definition:&lt;/p&gt;

&lt;p class=&quot;st-markup&quot;&gt;Your controller must provide some data to the template but &lt;br /&gt;
the template takes it from there requesting as much or as little as it needs, by being able to call methods on objects or dereference complex data structures.&lt;/p&gt;

&lt;p class=&quot;st-markup&quot;&gt;In your cotroller:&lt;/p&gt;

&lt;code&gt;&lt;br /&gt;
my&amp;#160;%data&amp;#160;=&amp;#160;(&amp;#160;navigation&amp;#160;&amp;#160;=&amp;gt;&amp;#160;$nav_object,&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;data&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;=&amp;gt;&amp;#160;$some_deep_complex_datastruct,&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;ExampleList&amp;#160;=&amp;gt;&amp;#160;&amp;#160;NewRecordSet('SELECT&amp;#160;Name,&amp;#160;Description&amp;#160;FROM&amp;#160;phpmodules');&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
my&amp;#160;$t&amp;#160;=&amp;#160;Template-&amp;gt;new('path/to/template',&amp;#160;\%data&amp;#160;);&lt;br /&gt;
&lt;br /&gt;
&lt;/code&gt;&lt;p class=&quot;st-markup&quot;&gt;And your template:&lt;/p&gt;

&lt;code&gt;&lt;br /&gt;
&amp;lt;li&amp;gt;&lt;br /&gt;
[%&amp;#160;FOREACH&amp;#160;module&amp;#160;IN&amp;#160;ExampleList&amp;#160;%]&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;lt;li&amp;gt;[%&amp;#160;module.name&amp;#160;%]&amp;#160;:&amp;#160;[%&amp;#160;module.description&amp;#160;%]&lt;br /&gt;
[%&amp;#160;END&amp;#160;%]&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/code&gt;</description>
		</item>
		<item>
			<title>by Keith</title>
			<link>http://keithdevens.com/weblog/archive/2004/Jun/22/templating#comment4856</link>
			<guid isPermaLink="false">http://keithdevens.com/weblog/4965#comment4856</guid>
			<pubDate>Thu, 24 Jun 2004 18:43:09 +0000</pubDate>
			<description>&lt;p class=&quot;st-markup&quot;&gt;Nope, that's still not pull as I meant it. That's the same as WACT where you're still &lt;em&gt;pushing&lt;/em&gt;, you're just giving an iterator instead of the full data set.&lt;/p&gt;

</description>
		</item>
		<item>
			<title>by Harry Fuecks</title>
			<link>http://keithdevens.com/weblog/archive/2004/Jun/22/templating#comment4865</link>
			<guid isPermaLink="false">http://keithdevens.com/weblog/4965#comment4865</guid>
			<pubDate>Fri, 25 Jun 2004 22:42:15 +0000</pubDate>
			<description>&lt;p class=&quot;st-markup&quot;&gt;True the example pushes an iterator to the template but the names of the variables from each row in the result set only exist in the template - it pulls them out of each row.&lt;/p&gt;

&lt;p class=&quot;st-markup&quot;&gt;Perhaps what the example doesn't make clear is it will also work if the SQL query is;&lt;/p&gt;

&lt;p class=&quot;st-markup&quot;&gt;'SELECT * FROM phpmodules'&lt;/p&gt;

&lt;p class=&quot;st-markup&quot;&gt;instead of naming columns in the query.&lt;/p&gt;

&lt;p class=&quot;st-markup&quot;&gt;Only the template knows the names of the variables it wants from each row - the controller doesn't know this, as you were saying;&lt;/p&gt;

&lt;p class=&quot;st-markup&quot;&gt;&amp;quot;the controller doesn't have to know what variables your template needs&amp;quot;&lt;/p&gt;

&lt;p class=&quot;st-markup&quot;&gt;There are other examples in WACT where data can be loaded with the controller knowing absolutely nothing about it, using the core:import tag e.g.;&lt;/p&gt;

&lt;code&gt;&lt;span style=&quot;color: #c00&quot;&gt;&amp;lt;&lt;span style=&quot;color: #00c&quot;&gt;body&lt;/span&gt;&lt;span style=&quot;color: #060&quot;&gt;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style=&quot;color: #c00&quot;&gt;&amp;lt;&lt;span style=&quot;color: #00c&quot;&gt;h1&lt;/span&gt;&lt;span style=&quot;color: #060&quot;&gt;&amp;#160;align=&amp;quot;center&amp;quot;&lt;/span&gt;&amp;gt;&lt;/span&gt;Import&amp;#160;Example&lt;span style=&quot;color: #c00&quot;&gt;&amp;lt;&lt;span style=&quot;color: #00c&quot;&gt;/h1&lt;/span&gt;&lt;span style=&quot;color: #060&quot;&gt;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style=&quot;color: #c00&quot;&gt;&amp;lt;&lt;span style=&quot;color: #00c&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color: #060&quot;&gt;&lt;/span&gt;&amp;gt;&lt;/span&gt;This&amp;#160;is&amp;#160;an&amp;#160;example&amp;#160;of&amp;#160;using&amp;#160;the&amp;#160;IMPORT&amp;#160;tag&amp;#160;to&amp;#160;import&lt;br /&gt;
values&amp;#160;from&amp;#160;a&amp;#160;var&amp;#160;file&amp;#160;into&amp;#160;the&amp;#160;current&amp;#160;template.&lt;span style=&quot;color: #c00&quot;&gt;&amp;lt;&lt;span style=&quot;color: #00c&quot;&gt;/p&lt;/span&gt;&lt;span style=&quot;color: #060&quot;&gt;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style=&quot;color: #f90&quot;&gt;&amp;lt;!--&amp;#160;Imports&amp;#160;data&amp;#160;from&amp;#160;file&amp;#160;at&amp;#160;compile&amp;#160;time&amp;#160;--&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;lt;core:IMPORT&amp;#160;file=&amp;quot;favorites.vars&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style=&quot;color: #c00&quot;&gt;&amp;lt;&lt;span style=&quot;color: #00c&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color: #060&quot;&gt;&lt;/span&gt;&amp;gt;&lt;/span&gt;Favorite&amp;#160;Fruit:&amp;#160;{$Fruit}&lt;span style=&quot;color: #c00&quot;&gt;&amp;lt;&lt;span style=&quot;color: #00c&quot;&gt;/p&lt;/span&gt;&lt;span style=&quot;color: #060&quot;&gt;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style=&quot;color: #c00&quot;&gt;&amp;lt;&lt;span style=&quot;color: #00c&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color: #060&quot;&gt;&lt;/span&gt;&amp;gt;&lt;/span&gt;Favorite&amp;#160;Vegatable:&amp;#160;{$Vegatable}&lt;span style=&quot;color: #c00&quot;&gt;&amp;lt;&lt;span style=&quot;color: #00c&quot;&gt;/p&lt;/span&gt;&lt;span style=&quot;color: #060&quot;&gt;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;span style=&quot;color: #c00&quot;&gt;&amp;lt;&lt;span style=&quot;color: #00c&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color: #060&quot;&gt;&lt;/span&gt;&amp;gt;&lt;/span&gt;Favorite&amp;#160;Color:&amp;#160;{$Color}&lt;span style=&quot;color: #c00&quot;&gt;&amp;lt;&lt;span style=&quot;color: #00c&quot;&gt;/p&lt;/span&gt;&lt;span style=&quot;color: #060&quot;&gt;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #c00&quot;&gt;&amp;lt;&lt;span style=&quot;color: #00c&quot;&gt;/body&lt;/span&gt;&lt;span style=&quot;color: #060&quot;&gt;&lt;/span&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;/code&gt;

&lt;p class=&quot;st-markup&quot;&gt;The imported file looks like;&lt;/p&gt;

&lt;code&gt;Color&amp;#160;=&amp;#160;Blue&lt;br /&gt;
Fruit&amp;#160;=&amp;#160;Apple&lt;br /&gt;
Vegatable&amp;#160;=&amp;#160;Carrot&lt;br /&gt;
&lt;/code&gt;

&lt;p class=&quot;st-markup&quot;&gt;Thats a specific instance though.&lt;/p&gt;

&lt;p class=&quot;st-markup&quot;&gt;In general think a mix of push and pull works well. Pure push generally means excessive work on the controller side - the &amp;quot;Pinhole API&amp;quot; while pure pull requires, to be useful, will likely require a fairly complex template language for locating data (e.g. XSLT ish).&lt;/p&gt;

&lt;p class=&quot;st-markup&quot;&gt;There is an example of a pure pull template engine, now I come to think of it, with eZ publish 3.x. Have a look &lt;a href=&quot;http://ez.no/ez_publish/documentation/customization/custom_design/examples/template_language&quot;&gt;here&lt;/a&gt;. Generally eZ publish 3.x wants to keep users completely away from controllers. The template language refers to a &amp;quot;content object&amp;quot; hierarchy (stored in a database).&lt;/p&gt;

</description>
		</item>
		<item>
			<title>by henq</title>
			<link>http://keithdevens.com/weblog/archive/2004/Jun/22/templating#comment5312</link>
			<guid isPermaLink="false">http://keithdevens.com/weblog/4965#comment5312</guid>
			<pubDate>Fri, 20 Aug 2004 19:18:58 +0000</pubDate>
			<description>&lt;p class=&quot;st-markup&quot;&gt;What you need for true pull are imho:&lt;/p&gt;

&lt;ul class=&quot;st-markup&quot;&gt;
	&lt;li&gt;Access to all data from within the template;&lt;/li&gt;
&lt;/ul&gt;

&lt;p class=&quot;st-markup&quot;&gt;This means you dont need statements in the controller to push the vars-t-display into the template.&lt;br /&gt;
The solution is an dot-notation that maps to the datastructure of the app. Template Tooolkit (perl) does this. Tapestry too, with &lt;a href=&quot;http://www.ognl.org&quot;&gt;http://www.ognl.org&lt;/a&gt;. &lt;/p&gt;

&lt;ul class=&quot;st-markup&quot;&gt;
	&lt;li&gt;Two-way binding of vars with form input elements;&lt;/li&gt;
&lt;/ul&gt;

&lt;p class=&quot;st-markup&quot;&gt;This way you don't need special vars in the controller to catch the submitted form. (your objects may be form-handling aware by providing 'old' values of each bound property until the new values all validate). &lt;/p&gt;

&lt;ul class=&quot;st-markup&quot;&gt;
	&lt;li&gt;Access to all (public) methods;&lt;/li&gt;
&lt;/ul&gt;

&lt;p class=&quot;st-markup&quot;&gt;So the template can call methods (i.e. to fetch data from a db) in a controlled way. (sql in the template is imo verboten). Using the dot notation and asuming the data is an graph of objects, we could just call a method from our template like this:&lt;br /&gt;
   session.currentuser.logout&lt;br /&gt;
logout can be a method, if it returns a value we want to display, we can do that too. &lt;/p&gt;

&lt;p class=&quot;st-markup&quot;&gt;&lt;a href=&quot;http://jakarta.apache.org/tapestry/&quot;&gt;http://jakarta.apache.org/tapestry/&lt;/a&gt; is a web application framework that uses 'true pull' in the way I tried to outline above. (is at least my concusion, I am not familiar with it in detail). &lt;/p&gt;

&lt;p class=&quot;st-markup&quot;&gt;Tapestry has another feature which is very sophisticated, I have to explain by an example. Say you display a number of rows of records from a table (a very common thing). On each row you have a link 'Delete' that deletes that record. The usual way to this is to fumble things in such a way that in the end behind each 'Delete' link there is an url with the record key encoded, like: &lt;br /&gt;
    .....&amp;amp;id=328&lt;/p&gt;

&lt;p class=&quot;st-markup&quot;&gt;In Tapestry this is not needed. When Tapestry displayes the rows (actally objects) it creates temporary id that identifie these objects by their position in the total object-graph. The 'Delete' link contains something like&lt;br /&gt;
     ....22.4.37.delete&lt;br /&gt;
where the numbers point to runtime generated objects. (Tapestry is Java based, so think only objects). So you get a lot of household chore done for you, but this way of doing has it drawbacks too, see &lt;a href=&quot;http://jakarta.apache.org/tapestry/doc/DevelopersGuide/pages.stale-links.html&quot;&gt;http://jakarta.apache.org/tapestry/doc/DevelopersGuide/pages.stale-links.html&lt;/a&gt; (Directlink is similar to the &amp;amp;id=328 way of doing, Actionlink is pure OO).&lt;/p&gt;

&lt;p class=&quot;st-markup&quot;&gt;Tapestry's template syntax has some nice touches too.  &amp;lt;span&amp;gt; can be used, and the spanned data is replaced by the actual value, This means the template designer can put sample data between the tags, so the templates have a good preview at design time:&lt;br /&gt;
   &amp;lt;span ...&amp;gt;Test text&amp;lt;/span&amp;gt;&lt;/p&gt;

&lt;p class=&quot;st-markup&quot;&gt;henq&lt;/p&gt;

</description>
		</item>
		<item>
			<title>by Keith Gaughan</title>
			<link>http://keithdevens.com/weblog/archive/2004/Jun/22/templating#comment5314</link>
			<guid isPermaLink="false">http://keithdevens.com/weblog/4965#comment5314</guid>
			<pubDate>Sat, 21 Aug 2004 05:13:07 +0000</pubDate>
			<description>&lt;p class=&quot;st-markup&quot;&gt;Keith, your StructuredText parser is after screwing up. In comment #5312, just after &amp;quot;Access to all data from within the template&amp;quot;, Mozilla reports that it's expecting a &amp;lt;/p&amp;gt; tag and refuses point blank to display the page.&lt;/p&gt;

&lt;p class=&quot;st-markup&quot;&gt;I need to use IE to post this. Eww, I feel all dirty!&lt;/p&gt;

</description>
		</item>
		<item>
			<title>by Keith</title>
			<link>http://keithdevens.com/weblog/archive/2004/Jun/22/templating#comment5315</link>
			<guid isPermaLink="false">http://keithdevens.com/weblog/4965#comment5315</guid>
			<pubDate>Sat, 21 Aug 2004 06:58:32 +0000</pubDate>
			<description>&lt;p class=&quot;st-markup&quot;&gt;Fixed. Thanks. I &lt;em&gt;gotta&lt;/em&gt; replace this code.&lt;/p&gt;

</description>
		</item>
	</channel>
</rss>
