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

Re: [Cheetahtemplate-discuss] #def & #extends

Expand Messages
  • Mike Orr
    ... What would it do? Call the superclass method and then the current method? But people want to insert the new content at an arbitrary place in the old, not
    Message 1 of 3 , Feb 28, 2007
    • 0 Attachment
      On 2/28/07, Sandro Dentella <sandro@...> wrote:
      > On Wed, Feb 28, 2007 at 07:53:05AM -0800, Mike Orr wrote:
      > > On 2/28/07, Sandro Dentella <sandro@...> wrote:
      > > > Hi,
      > > >
      > > > is there a way to just *add* to a block w/o overriding what already has in
      > > > an ancestor?
      > > >
      > > > I have a 'css' block with css definitions for an html page defined in
      > > > base.tmpl.
      > > >
      > > > In my_page.tmpl I '#extends base', but at that point I'd like to add a css
      > > > page, not just rewrite from scratch: following code works, I was just
      > > > wandering if there is a smarter/more correct way.
      > >
      > > That's the best way. It's an issue that never came up when the
      > > directive was created, but suddenly the past few months people have
      > > been asking about.
      >
      > Would it be difficult to just add a '+' in the syntax?
      >
      > #def +css
      > or
      > #def + css
      >
      > that shouldn't brake already existing templates

      What would it do? Call the superclass method and then the current
      method? But people want to insert the new content at an arbitrary
      place in the old, not necessarily at the beginning or end.

      Another issue is which superclass method is called. Do we just use
      whatever super() decides?

      If we're going to change this I'd rather use Mako's system as a model
      because it's much more flexible. Mako has 'next' and 'parent'
      variables that point up and down the inheritance chain, making it easy
      to call the child or parent method at any point. Mako also has 'self'
      pointing to the youngest template where the method is defined, but
      Cheetah already has that. One bit of magic is that ${next.body()} is
      a bound method so you don't have to pass $self explicitly. But Mako
      uses a kind of pseudo inheritance rather than true class inheritance
      so i don't know how portable their design is.

      http://www.makotemplates.org/docs/inheritance.html

      --
      Mike Orr <sluggoster@...>

      -------------------------------------------------------------------------
      Take Surveys. Earn Cash. Influence the Future of IT
      Join SourceForge.net's Techsay panel and you'll get the chance to share your
      opinions on IT & business topics through brief surveys-and earn cash
      http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
      _______________________________________________
      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.