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

1343Re: [Cheetahtemplate-discuss] blocks and locals

Expand Messages
  • Tavis Rudd
    Aug 1, 2002
    • 0 Attachment
      On July 31, 2002 08:39 pm, Greg Czajkowski wrote:
      > Hi all,
      > I wanted to know why locals() are never added to the
      > searchlist for block directives?
      > In the following code shouldn't I be able to use $i
      > without declaring it global?
      > from Cheetah.Template import Template
      > print Template(source="""
      > #for $i in range(10)
      > #block testblock
      > testing $i
      > #end block
      > #end for
      > """)
      > BTW. I understand the implementation behind #block,
      > can *my* local implementation be changed to
      > temporarily add the locals() to the called testblock
      > function's searchList? And then they would be removed
      > right after?? something like
      > self._searchList.addToSearchList(locals())
      > self.blockName() # Calls the created functions
      > self._searchList.pop()

      I'm not sure why you would want to do that. It's simpler and cleaner to do
      something like this:

      from Cheetah.Template import T
      print T("""
      #def testBlock($i)
      testing $i
      #end def
      #for $i in $range(10)
      #end for


      This sf.net email is sponsored by:ThinkGeek
      Welcome to geek heaven.
      Cheetahtemplate-discuss mailing list
    • Show all 4 messages in this topic