Cheetah 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 :-)

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):

  1. Assume you have a template Package/Page.tmpl like that:

    #def footer
      This is my foot !
    #end def
  2. Create a Page_custom.tmpl template:

    #extends Package.Page
    #def footer
      $Page.footer($self) Where's my mind ? (dixit the Pixies)
    #end def
  3. You need to put a self variable in the template’s searchList which is the Cheetah template instance itself :-)

I don’t think that trick will work if you don’t compile your templates to Python code.


comments powered by Disqus