Found it. Turbogears has a nice way of handling this using
'turbogears.view.render'.
For example:
return turbogears.view.render(info=dict(xpos=x, ypos=y),
template='webapp.templates.window')
Will return the string with variables from info inserted into template.
Default encoding is html but that can be changed.
Justin Johnson wrote:
Hi, I've been rummaging around in the documentation but this has
eluded me.
I've got a url mapping to an ajax call. The intention is to return a
lump of html that's injected into the page client side.
So ideally, my ajax call should return a string which is the product
of a kid template with some variable insertions.
Question is, how do I manually call kid to generate a string given a
kid template and a variable dictionary?
There may be another way, but in TurboStan to render Kid fragments, I
just do something like this:
import kid
s = "some kid template stuff"
template = kid.Template(source = s) return template.serialize()
I use **kwargs cause I just transparently pass user-supplied info, but
you'd probably use source = "<template>".
Regards,
Cliff