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

[Cheetahtemplate-discuss] Understanding template inheritance

Expand Messages
  • Alex Gonzalez
    Hi, I have been trying to understand what am I missing to make the following example work, but I have given up. I have two templates, parent.tmpl $placeholder
    Message 1 of 1 , Apr 29, 2007
    • 0 Attachment
      Hi,

      I have been trying to understand what am I missing to make the
      following example work, but I have given up.

      I have two templates,

      parent.tmpl

      $placeholder

      child.tmpl

      #from parent import parent
      #extends parent

      #def placeholder
      $child_placeholder
      #end def

      Then I do,

      cheetah c parent.tmpl
      Compiling parent.tmpl -> parent.py

      And in the same folder that contains the templates I enter the python shell,

      Python 2.4.4c1 (#2, Oct 11 2006, 21:51:02)
      [GCC 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu5)] on linux2
      Type "help", "copyright", "credits" or "license" for more information.
      >>> from Cheetah.Template import Template
      >>> ns = {'child_placeholder':'something'}
      >>> tmpl = Template(file='child.tmpl',searchList=[ns])
      >>> tmpl.respond()
      Traceback (most recent call last):
      File "<stdin>", line 1, in ?
      File "parent.py", line 87, in respond
      write(filter(VFFSL(SL,"placeholder",True),
      rawExpr='$placeholder')) # from line 1, col 1.
      File "<string>", line 25, in placeholder
      NameMapper.NotFound: cannot find 'child_placeholder' while searching
      for 'placeholder'
      >>>

      This example works if I do,

      cheetah -c child.tmpl
      Compiling child.tmpl -> child.py
      child_placeholder='something'
      export child_placeholder
      ./child.py --env
      something

      I am using,

      cheetah --version
      0.9.16

      Any pointers will be appreciated,
      Thanks,
      Alex

      -------------------------------------------------------------------------
      This SF.net email is sponsored by DB2 Express
      Download DB2 Express C - the FREE version of DB2 express and take
      control of your XML. No limits. Just data. Click to get it now.
      http://sourceforge.net/powerbar/db2/
      _______________________________________________
      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.