<?xml version="1.0" encoding="iso-8859-1"?>
<rdf:RDF xmlns="http://purl.org/rss/1.0/"
         xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
         xmlns:dc="http://purl.org/dc/elements/1.1/"
         xmlns:content="http://purl.org/rss/1.0/modules/content/">

<channel rdf:about="http://base-art.net/Articles/44/">
<description>&lt;p&gt;&lt;a class="reference" href="http://cheetahtemplate.org/"&gt;Cheetah&lt;/a&gt; is a very good templating language, especially because it's
the one (correct me if i'm wrong) to apply the Object-Oriented model
to Documents. It can seem a bit weird at the beginning but when you get
used to it, you can't live without it :-)&lt;/p&gt;
&lt;p&gt;So, i was looking for a good way to overload template parts without
pain, here is how (couldn't find the trick on Cheetah doc):&lt;/p&gt;
&lt;ol class="arabic"&gt;
&lt;li&gt;&lt;p class="first"&gt;Assume you have a template &lt;tt class="literal"&gt;&lt;span class="pre"&gt;Package/Page.tmpl&lt;/span&gt;&lt;/tt&gt; like that:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
#def footer
  This is my foot !
#end def
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;Create a &lt;tt class="literal"&gt;&lt;span class="pre"&gt;Page_custom.tmpl&lt;/span&gt;&lt;/tt&gt; template:&lt;/p&gt;
&lt;pre class="literal-block"&gt;
#extends Package.Page

#def footer
  $Page.footer($self) Where's my mind ? (dixit the Pixies)
#end def
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p class="first"&gt;You need to put a &lt;tt class="literal"&gt;&lt;span class="pre"&gt;self&lt;/span&gt;&lt;/tt&gt; variable in the template's searchList
which is the Cheetah template instance itself :-)&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I don't think that trick will work if you don't compile your templates
to Python code.&lt;/p&gt;
</description>
<link>http://base-art.net/Articles/44/</link>
<title>Comments on article "Cheetah templates overriding"</title>



<items>
<rdf:seq>

<rdf:li rdf:resource="http://base-art.net/Comments/159/"/>

<rdf:li rdf:resource="http://base-art.net/Comments/158/"/>

</rdf:seq>
</items>


</channel>


<item rdf:about="http://base-art.net/Comments/159/">
<dc:date>2005-08-12T14:16:57.000004+01:00</dc:date>
<title>phil on Cheetah templates overriding</title>
<link>http://base-art.net/Comments/159/</link>
<author>phil</author>
<description>
&lt;p&gt;Good point Deelan ;)&lt;/p&gt;
&lt;p&gt;Actually the same trick is used by the framework behind this blog, but with #defS instead of #blockS&lt;/p&gt;
&lt;p&gt;See the basic template:&lt;/p&gt;
&lt;p&gt;&lt;a class="reference" href="http://svn.pythonfr.org/public/alinea/Alinea/templates/SitePage.tmpl"&gt;http://svn.pythonfr.org/public/alinea/Alinea/templates/SitePage.tmpl&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;And one custom template (the #extends is added a posteriori):&lt;/p&gt;
&lt;p&gt;&lt;a class="reference" href="http://svn.pythonfr.org/public/alinea/Alinea/designs/redFlower/SitePage_c.tmpl"&gt;http://svn.pythonfr.org/public/alinea/Alinea/designs/redFlower/SitePage_c.tmpl&lt;/a&gt;&lt;/p&gt;

</description>
</item>

<item rdf:about="http://base-art.net/Comments/158/">
<dc:date>2005-08-12T13:27:27.000004+01:00</dc:date>
<title>deelan on Cheetah templates overriding</title>
<link>http://base-art.net/Comments/158/</link>
<author>deelan</author>
<description>
&lt;p&gt;&amp;quot;I don't think that trick will work if you don't compile your templates to Python code.&amp;quot;&lt;/p&gt;
&lt;p&gt;Correct, actually you have to precompile the base class.&lt;/p&gt;
&lt;p&gt;In Subway[1] we managed to automatically compile the whole template hierarchy upon request. Builiding web site using Cheetah and his #extends directive is great. As you have written you can write some default markup into parent template #blockS and then override only when you really need to. No more ugly includes :)&lt;/p&gt;
&lt;p&gt;For example, base site.html:&lt;/p&gt;
&lt;p&gt;&lt;a class="reference" href="http://subway.python-hosting.com/file/sandbox/bikini/view/site.html"&gt;http://subway.python-hosting.com/file/sandbox/bikini/view/site.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;and one view which overrides both &amp;quot;content&amp;quot; and &amp;quot;nav&amp;quot; #blocks:&lt;/p&gt;
&lt;p&gt;&lt;a class="reference" href="http://subway.python-hosting.com/file/sandbox/bikini/view/entry/show.html"&gt;http://subway.python-hosting.com/file/sandbox/bikini/view/entry/show.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;-- deelan&lt;/p&gt;
&lt;p&gt;[1] &lt;a class="reference" href="http://subway.python-hosting.com/"&gt;http://subway.python-hosting.com/&lt;/a&gt;&lt;/p&gt;

</description>
</item>


</rdf:RDF>
