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

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

Expand Messages
  • Mike Orr
    ... You can do this several ways. 1) Inheritance and #block, as we ve been discussing. 2) #include. 3) A Python program that invokes several little templates
    Message 1 of 41 , Nov 2, 2002
    • 0 Attachment
      On Sat, Nov 02, 2002 at 03:59:03AM -0600, jamie@... wrote:
      > a template might only define a tiny piece of a page and then get
      > "embedded" in a larger template.

      You can do this several ways.

      1) Inheritance and #block, as we've been discussing.
      2) #include.
      3) A Python program that invokes several little templates and
      joins the output together.
      4) A Python program that invokes several little templates and
      places their output in searchList variables for a larger
      template. That's what Edmund meant about putting an entire
      HTML structure in a placeholder value.
      5) A template instance can itself be a placeholder value. When
      the NameMapper looks it up, it will automatically fill the
      subtemplate and insert the result in the output.

      > in other words, how does sometimes class/template A inherit class B and then
      > other times the other way around -- and all in the same program and all
      > completely programmatically?

      You can't do that with the ordinary use of classes. You can do it
      if you use Python tricks to dynamically change an object's base
      classes. Cheetah's compiler actually does this, and it's the part
      of Cheetah that's black art and voodoo.

      Rather than doing tricks with inheritance, I'd suggest containment
      instead. Code each unit as a pure function that gets all its input
      from its arguments. Then you can combine them in any combination
      you wish without having to deal with dynamic classes and complicated
      inheritance. Or if the unit needs to share state information between
      a few cooperative methods, code it as a standalone class.

      --
      -Mike (Iron) Orr, iron@... (if mail problems: mso@...)
      http://iron.cx/ English * Esperanto * Russkiy * Deutsch * Espan~ol


      -------------------------------------------------------
      This sf.net email is sponsored by: See the NEW Palm
      Tungsten T handheld. Power & Color in a compact size!
      http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en
      _______________________________________________
      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.