Hancock, David (DHANCOCK) wrote:
> One of the things we're working on is getting our form code a bit more
> abstracted, and FormEncode is looking pretty good to us. Another thing
> we're looking at is templating with ZPT. Has anyone got a recipe for
> using both at once? It seems like a good use of ComponentKit, but I
> haven't got a clue where to start.
> Conceptually, I'm hoping to see the template read (preferably from
> memory, not disk), and then htmlfill (from FormEncode) called on the
> template. Does this sound like the right approach?
I've only had the chance to use it once so far. In that, I had a
completely separate template for the form, and then a template for the
container. So I did:
tmpl = self.template('form.pt')
html = tmpl(**options)
And then passed that into htmlfill, and then used <tal:insert
replace="structure form_html"/> to put it in the containing page. A
little crude; it's more elegant if the entire page went through
htmlfill. Of course, it'd be even more efficient if ZPT's internal
structure (since it must have some structure for the tags) wasn't
serialized into text until after htmlfill (or an equivalent) did its job.
Ian Bicking / ianb@... / http://blog.ianbicking.org