The Artima Developer Community
Sponsored Link

Python Buzz Forum
Cheetah templates overriding

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Philippe Normand

Posts: 78
Nickname: philn
Registered: Aug, 2005

Philippe Normand is a developer
Cheetah templates overriding Posted: Aug 16, 2005 4:51 AM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Philippe Normand.
Original Post: Cheetah templates overriding
Feed Title: Base-Art / Python
Feed URL: http://base-art.net/Sections/5/rss.xml
Feed Description: Phil's blog
Latest Python Buzz Posts
Latest Python Buzz Posts by Philippe Normand
Latest Posts From Base-Art / Python

Advertisement

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.

Read: Cheetah templates overriding

Topic: 4Suite Previous Topic   Next Topic Topic: The Harry Potter Theory of Programming Language Design

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use