On Wed, Sep 10, 2008 at 07:57:29PM -0700, David Bear wrote:
> I have a script that calls a template.
> The template has a tal expressions like this
> <p tal:content="structure here/ploneDoc/getText"> </p>
> I want my script to call the template in such a way that the string
> 'ploneDoc' is replaced by a different string.
> I'm not sure how to go about parameterizing a tales expressions like
> this.

It is possible, by sticking a question mark in front of ploneDoc; but
afaict you can only use a variable already in the namespace,
i.e. you'd have to define it first.  Like so:

 <p tal:define="docname options/ploneDoc"
    tal:content="structure here/?docname/getText"> </p>

But I have literally never seen this obscure feature in real use,
because nobody seems to know about it (I had forgotten it myself), and
because it's not necessary. I'd prefer to have the script just pass in
the object you want, as per this document:

So, in your script, something like:

doc = context.restrictedTraverse(some_path)
return context.mytemplate(mydoc=doc)

Then, in your template just do:

<p tal:content="structure options/mydoc/getText"></p>


Paul Winkler
Zope maillist  -  Zope@zope.org
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to