Re: [Cheetahtemplate-discuss] problem using include and def
Brought to you by:
rtyler,
tavis_rudd
From: Tavis R. <ta...@da...> - 2007-10-10 22:13:23
|
Hi Israel, The variables in included templates belong to a separate namespace. Try=20 either importing file2 (#import) or inheriting from it (#extends). In=20 general, I recommend avoiding the #include usage pattern. Cheers, Tavis On Wed, 10 Oct 2007, Israel Saeta P=E9rez wrote: > Hello: > > I'm trying to use a defined method throught an include in a template, > but it fails. Here's what I'm doing: > > ----- > ***** file1: > #include 'file2' > $variable1 > > ***** file2: > #def variable1 > some text > #end def > > TRACEBACK: > [dukebody@tux cheetah]$ cheetah fill file1 > Filling file1 -> file1.html > Traceback (most recent call last): > File "/usr/bin/cheetah", line 3, in <module> > CheetahWrapper().main() > File "/usr/lib/python2.5/site-packages/Cheetah/CheetahWrapper.py", line = 183, in main > meth() > File "/usr/lib/python2.5/site-packages/Cheetah/CheetahWrapper.py", line = 245, in fill > self._compileOrFill() > File "/usr/lib/python2.5/site-packages/Cheetah/CheetahWrapper.py", line = 347, in _compileOrFill > self._compileOrFillBundle(b) > File "/usr/lib/python2.5/site-packages/Cheetah/CheetahWrapper.py", line = 568, in _compileOrFillBundle > output =3D str(tclass(searchList=3Dself.searchList)) > File "/usr/lib/python2.5/site-packages/Cheetah/Template.py", line 994, i= n __str__ > def __str__(self): return getattr(self, mainMethName)() > File "file1.py", line 87, in respond > NameMapper.NotFound: cannot find 'variable1' > ----- > > > What am I doing wrong? > > Cheers, > Israel Saeta P=E9rez. > http://dukebody.blogsome.com > > Nothing so needs reforming as other people's habits. > -- Mark Twain > > |