[Zope] Re: including a ZPT inside a repeat loop
Tres Seaver
tseaver at palladion.com
Tue Sep 27 13:02:18 EDT 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Matthew White wrote:
> oops! I thought I'd clean up my code snippet to make it a little more
> readable, and instead introduced an error. Here it is in full:
>
> <tal:loop repeat="t python:test(exists('/request/form/view_all'),
> container.py.new_get_queue(whence=q),
> container.py.new_get_queue(whence=q, userid=userid))">
>
> <span tal:replace="structure here/queue_template">
> Queue Template Goes Here
> </span>
Names defined in one template are only available within that template,
or within macros it inlines. Your case *calls* the second template, and
so would need to pass 't' along explicitly, e.g.:
<span tal:replace="structure python:here.queue_template(t=t)" />
In that case, the 'queue_template' script would use 'options/t' to get
to the passed value, e.g::
<div>
<h1 tal:content="options/t">T</h1>
</div>
An alternative spelling would be to add a 'metal:define-macro="qt"'
attribute to your 'queue_template', and then include it as a macro, e.g.:
<!-- In 'queue_template'; expects to find the name 't' bound
in the TAL namespace.
-->
<div metal:define-macro="qt">
<h1 tal:content="t">T</h1>
</div>
and::
<span metal:use-macro="here/queue_template/macros/qt" />
Tres.
- --
===================================================================
Tres Seaver +1 202-558-7113 tseaver at palladion.com
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFDOXsa+gerLs4ltQ4RAhZiAJ4h+15swFdO/F06QI+Zc5ULZcFACgCgmYT2
BeTqOab8BRcM5+gtK2+6Xlk=
=9iF+
-----END PGP SIGNATURE-----
More information about the Zope
mailing list