Loading ...
Sorry, an error occurred while loading the content.

Re: [Cheetahtemplate-discuss] #block vs #def

Expand Messages
  • Edmund Lian
    ... an ... of ... That someone was me. For your specific situation, I was suggesting that you use Cheetah s inheritance mechanism. This is, I feel, one of the
    Message 1 of 41 , Oct 31, 2002
    • 0 Attachment
      On 10/31/2002 10:42:49 PM Jamie wrote:

      >Can someone clarify the difference between #block and #def, perhaps with
      an
      >example? I noticed a mention in one of the other emails that that section
      of
      >the manual should be studied, but, frankly, I'm not sure I understand the
      >difference. Maybe this is the answer to my other question...

      That someone was me. For your specific situation, I was suggesting that you
      use Cheetah's inheritance mechanism. This is, I feel, one of the most
      important organizational tools you have for setting up site frameworks. The
      example you want follows...

      Base template "MyBaseTemplate.tmpl":

      ## Import modified base logic class--you would use the standard Cheetah
      SkeletonPage
      #from SiteLib.SkeletonPage import SkeletonPage

      #extends SkeletonPage
      #implements respond
      <html>
      <head>
      #block head
      Default head content
      #end block
      </head>
      <body>
      #block body
      Default body content
      #end block


      Subclassed template "SubclassedTemplate.tmpl":

      #extends MyBaseTemplate

      #def head
      This content overrides/replaces the default head content
      #end def


      In the (very) brief snippet, the subclassed template has selectively
      overridden only the first of two defined #blocks in the template. By using
      #blocks in all the portions of the base template that you want to fill with
      content in subclassed templates, you get to selectively over-ride portions
      of superclass templates.

      In my case for example, I have a hierarchy of template classes that I use
      to structure the content of the entire site:

      SiteTemplate
      +
      |
      +-- SubsiteTemplateA
      | +
      | |
      | +-- PageTemplateA
      |
      +-- SubsiteTemplateB
      | +
      | |
      | +-- PageTemplateB
      etc...


      Each template subclass overrides only the portions of the inherited
      template that it needs to specialize (does this make sense).

      ...Edmund.



      -------------------------------------------------------
      This sf.net email is sponsored by: Influence the future
      of Java(TM) technology. Join the Java Community
      Process(SM) (JCP(SM)) program now.
      http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0004en
      _______________________________________________
      Cheetahtemplate-discuss mailing list
      Cheetahtemplate-discuss@...
      https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
    • Mike Warren
      ... Yes, I agree. This is how I think of templates; templates should be able to own each other. ... Not to me it doesn t ;) -- mike [at] mike [dash] warren
      Message 41 of 41 , Nov 13, 2002
      • 0 Attachment
        jamie@... writes:

        > but what really makes me strange is that, to me, a template doesn't
        > (ie, if this is possible with Cheetah) define an entire page. it
        > MIGHT, but not necessarily. a template might only define a tiny
        > piece of a page and then get "embedded" in a larger template.

        Yes, I agree. This is how I think of templates; templates should be
        able to own each other.

        > Some templates will produce some sort of dynamic content -- such as
        > news headlines.. Originally I planned to separate "templates" that
        > produce different sorts of content physically -- but then I realized
        > that the distinction was logical. Ideally, I'd have different
        > classes of templates -- for example, themes vs layout vs content
        > producing, but inherently they still all should be able to extend
        > each other in various ways. OK, that sounds really nuts [..]

        Not to me it doesn't ;)

        --
        mike [at] mike [dash] warren [dot] com
        <URL:http://www.mike-warren.com>
        gpg --keyserver 80.71.227.37 --recv-key 579911BD
        87F2 4D98 BDB0 0E90 EE2A 0CF9 1087 0884 5799 11BD


        -------------------------------------------------------
        This sf.net email is sponsored by: Are you worried about
        your web server security? Click here for a FREE Thawte
        Apache SSL Guide and answer your Apache SSL security
        needs: http://www.gothawte.com/rd523.html
        _______________________________________________
        Cheetahtemplate-discuss mailing list
        Cheetahtemplate-discuss@...
        https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
      Your message has been successfully submitted and would be delivered to recipients shortly.