<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Introducing the Proton Template Engine</title>
	<atom:link href="http://www.briggs.net.nz/log/2009/01/20/introducing-proton/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.briggs.net.nz/log/2009/01/20/introducing-proton/</link>
	<description>Techie stuff from the perspective of a Kiwi abroad</description>
	<lastBuildDate>Sun, 29 Aug 2010 15:30:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: jrbriggs</title>
		<link>http://www.briggs.net.nz/log/2009/01/20/introducing-proton/comment-page-1/#comment-40870</link>
		<dc:creator>jrbriggs</dc:creator>
		<pubDate>Thu, 22 Jan 2009 09:10:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.briggs.net.nz/log/?p=484#comment-40870</guid>
		<description>You understand correctly, but the same code can be used for both templates.  Assuming either template has been loaded, this will work:

&lt;pre&gt;&lt;code&gt;
tmp.repeat(&#039;list&#039;, 2)
for x in range(1, 3):
    tmp.setelement(&#039;listid&#039;, str(x), x)
    tmp.setattribute(&#039;listid&#039;, &#039;id&#039;, str(x), x)
    tmp.setelement(&#039;listval&#039;, &#039;my item %s&#039; % x, x)
&lt;/code&gt;&lt;/pre&gt;

The engine won&#039;t add an attribute where one doesn&#039;t already exist in the template -- so the setattribute call won&#039;t affect the xhtml.  I&#039;ve added an example with assertions to source control if you&#039;re interested in taking a look:
http://proton-te.googlecode.com/hg/python/test/twotemplates.py</description>
		<content:encoded><![CDATA[<p>You understand correctly, but the same code can be used for both templates.  Assuming either template has been loaded, this will work:</p>
<pre><code>
tmp.repeat('list', 2)
for x in range(1, 3):
    tmp.setelement('listid', str(x), x)
    tmp.setattribute('listid', 'id', str(x), x)
    tmp.setelement('listval', 'my item %s' % x, x)
</code></pre>
<p>The engine won&#8217;t add an attribute where one doesn&#8217;t already exist in the template &#8212; so the setattribute call won&#8217;t affect the xhtml.  I&#8217;ve added an example with assertions to source control if you&#8217;re interested in taking a look:<br />
<a href="http://proton-te.googlecode.com/hg/python/test/twotemplates.py" rel="nofollow">http://proton-te.googlecode.com/hg/python/test/twotemplates.py</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://www.briggs.net.nz/log/2009/01/20/introducing-proton/comment-page-1/#comment-40867</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Wed, 21 Jan 2009 18:01:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.briggs.net.nz/log/?p=484#comment-40867</guid>
		<description>If I understand your post correctly, the code would be different for each template anyway.  The XML example would require a setelement() and a setattribute() call, while the XHTML example requires two setelement() calls.</description>
		<content:encoded><![CDATA[<p>If I understand your post correctly, the code would be different for each template anyway.  The XML example would require a setelement() and a setattribute() call, while the XHTML example requires two setelement() calls.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jrbriggs</title>
		<link>http://www.briggs.net.nz/log/2009/01/20/introducing-proton/comment-page-1/#comment-40818</link>
		<dc:creator>jrbriggs</dc:creator>
		<pubDate>Tue, 20 Jan 2009 09:40:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.briggs.net.nz/log/?p=484#comment-40818</guid>
		<description>Flexibility, basically.  I used to have a good example of this, but I&#039;ve forgotten it, so here&#039;s a completely contrived example.  Suppose you have 2 templates, one which is plain xml and one which is xhtml.  The input to both is the same, so you should be able to use the same code to populate/render output...

Plain xml template:
 
&lt;list&gt;
 &lt;item id=&quot;&quot; rid=&quot;list&quot; aid=&quot;listid&quot; eid=&quot;listval&quot;&gt;&lt;/item&gt;
&lt;/list&gt;
 
Final output:
 
&lt;list&gt;
 &lt;item id=&quot;1&quot;&gt;my item 1&lt;/item&gt;
 &lt;item id=&quot;2&quot;&gt;my item 2&lt;/item&gt;
&lt;/list&gt;
 
Xhtml template:
 
&lt;table&gt;
 &lt;tr rid=&quot;list&quot;&gt;
  &lt;td&gt;ID&lt;/td&gt;
  &lt;td eid=&quot;listid&quot;&gt;&lt;/td&gt;
  &lt;td&gt;VALUE&lt;/td&gt;
  &lt;td eid=&quot;listval&quot;&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;/table&gt;
 
Final output:
 
&lt;table&gt;
 &lt;tr&gt;
  &lt;td&gt;ID&lt;/td&gt;
  &lt;td&gt;1&lt;/td&gt;
  &lt;td&gt;VALUE&lt;/td&gt;
  &lt;td&gt;my item 1&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td&gt;ID&lt;/td&gt;
  &lt;td&gt;2&lt;/td&gt;
  &lt;td&gt;VALUE&lt;/td&gt;
  &lt;td&gt;my item 2&lt;/td&gt;
 &lt;/tr&gt;
&lt;/table&gt;

Without separating the setting of attribute values from element values, you wouldn&#039;t be able to use the same code for both the above templates -- or at the very least, you&#039;d have to add logic to the code which is &#039;aware&#039; of the content of the templates (which I&#039;d like to avoid).

PS.  You could end up with 4 &#039;id&#039; attributes on an element: id, eid, rid, aid.  The latter 3 are stripped on output, but in any case, it&#039;s no more annoying than your average JSF monstrosity... or other templating systems with screeds of code.  IMHO of course. ;-)</description>
		<content:encoded><![CDATA[<p>Flexibility, basically.  I used to have a good example of this, but I&#8217;ve forgotten it, so here&#8217;s a completely contrived example.  Suppose you have 2 templates, one which is plain xml and one which is xhtml.  The input to both is the same, so you should be able to use the same code to populate/render output&#8230;</p>
<p>Plain xml template:</p>
<p>&lt;list&gt;<br />
 &lt;item id=&#8221;" rid=&#8221;list&#8221; aid=&#8221;listid&#8221; eid=&#8221;listval&#8221;&gt;&lt;/item&gt;<br />
&lt;/list&gt;</p>
<p>Final output:</p>
<p>&lt;list&gt;<br />
 &lt;item id=&#8221;1&#8243;&gt;my item 1&lt;/item&gt;<br />
 &lt;item id=&#8221;2&#8243;&gt;my item 2&lt;/item&gt;<br />
&lt;/list&gt;</p>
<p>Xhtml template:</p>
<p>&lt;table&gt;<br />
 &lt;tr rid=&#8221;list&#8221;&gt;<br />
  &lt;td&gt;ID&lt;/td&gt;<br />
  &lt;td eid=&#8221;listid&#8221;&gt;&lt;/td&gt;<br />
  &lt;td&gt;VALUE&lt;/td&gt;<br />
  &lt;td eid=&#8221;listval&#8221;&gt;&lt;/td&gt;<br />
 &lt;/tr&gt;<br />
&lt;/table&gt;</p>
<p>Final output:</p>
<p>&lt;table&gt;<br />
 &lt;tr&gt;<br />
  &lt;td&gt;ID&lt;/td&gt;<br />
  &lt;td&gt;1&lt;/td&gt;<br />
  &lt;td&gt;VALUE&lt;/td&gt;<br />
  &lt;td&gt;my item 1&lt;/td&gt;<br />
 &lt;/tr&gt;<br />
 &lt;tr&gt;<br />
  &lt;td&gt;ID&lt;/td&gt;<br />
  &lt;td&gt;2&lt;/td&gt;<br />
  &lt;td&gt;VALUE&lt;/td&gt;<br />
  &lt;td&gt;my item 2&lt;/td&gt;<br />
 &lt;/tr&gt;<br />
&lt;/table&gt;</p>
<p>Without separating the setting of attribute values from element values, you wouldn&#8217;t be able to use the same code for both the above templates &#8212; or at the very least, you&#8217;d have to add logic to the code which is &#8216;aware&#8217; of the content of the templates (which I&#8217;d like to avoid).</p>
<p>PS.  You could end up with 4 &#8216;id&#8217; attributes on an element: id, eid, rid, aid.  The latter 3 are stripped on output, but in any case, it&#8217;s no more annoying than your average JSF monstrosity&#8230; or other templating systems with screeds of code.  IMHO of course. <img src='http://www.briggs.net.nz/log/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://www.briggs.net.nz/log/2009/01/20/introducing-proton/comment-page-1/#comment-40813</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Tue, 20 Jan 2009 04:53:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.briggs.net.nz/log/?p=484#comment-40813</guid>
		<description>Why does the &lt;a&gt; require both an &#039;eid&#039; and an &#039;aid&#039;?  I&#039;m curious why can&#039;t you use eid for both purposes.

In many sistuations, the element will also have an &#039;id&#039; attribute.  Does that mean you will end up having three &#039;id&#039; attributes?  That&#039;s going to be a bit annoying isn&#039;t it?</description>
		<content:encoded><![CDATA[<p>Why does the &lt;a&gt; require both an &#8216;eid&#8217; and an &#8216;aid&#8217;?  I&#8217;m curious why can&#8217;t you use eid for both purposes.</p>
<p>In many sistuations, the element will also have an &#8216;id&#8217; attribute.  Does that mean you will end up having three &#8216;id&#8217; attributes?  That&#8217;s going to be a bit annoying isn&#8217;t it?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
