[Zope] Render a string as tal

Paul Winkler pw_lists at slinkp.com
Tue Nov 15 20:46:44 EST 2005


On Tue, Nov 15, 2005 at 06:20:39PM -0700, Mark Gibson wrote:
> On Mon, 2005-11-14 at 13:38, Paul Winkler wrote:
> > On Mon, Nov 14, 2005 at 01:19:18PM -0700, Mark Gibson wrote:
> > > I would like to be able to render an arbitrary string as tal, having the
> > > tal statements evaluated correctly.
> > > 
> > > How would I go about doing this?
> > 
> > I assume you  mean TALES expressions.
> > See:
> > http://zopelabs.com/cookbook/1037762730
> 
> Thanks for your suggestion.  This has shed some light on the subject.
> 
> However, what I'm looking for is being able to take a string such as 
> '<div tal:content="here/absolute_url">The url</div>'
> 
> and be able to evaluate the TALES expression in the string to produced
> something like: '<div>http://mydomain.com/theUrl</div>'
> 
> Any chance there's a recipe for this?

Hmm. If you want TAL statements and all, I suspect you'll have to do as 
Chris suggested and instantiate a full-blown page template on the fly.
I've never done that, if I were going to try I'd probably just start
looking at the code in lib/python/Products/PageTemplates.

You might be able to instantiate a PageTemplate rather than
a ZopePageTemplate, which would be somewhat lighter as it leaves
out a lot of stuff you surely don't care about (FTP support,
ZMI management tabs, etc).

-- 

Paul Winkler
http://www.slinkp.com


More information about the Zope mailing list