[ZPT] Processing instructions in HTML with ZPT

Evan Simpson evan@zope.com
Mon, 29 Oct 2001 12:10:27 -0500


Brad Clements wrote:

> I'm trying to inject <?IMPORT tags in HTML output for some Page Templates.


Ack.  You may actually want to generate these from a script, since TAL makes 
no attempt to look inside processing instructions such as <?IMPORT>. 
Something like:

##parameters=namespaces
if namespaces:
   from string import split
   for ns in namespaces:
     args = tuple(split(ns, ':')[:2])
     print '<?IMPORT namespace="%s" implementation="%s">' % args
return printed

<tal:xyz define="namespaces template/import_Namespace"
          replace="structure python:here.show_imports(namespaces)" />

 
> 1. I would like to be able to specify xmlns:ps and xmlns:ts in the HTML header based 
> on some code that extracts these values from the import_Namespace property, 
> however I couldn't figure out any way to do this with Page Templates.


I take it that you don't just want 'xmlns:ps' and 'xmlns:ts', but whatever 
'xmlns:foo' is found in import_Namespace?  This is definitely a missing 
feature.  Perhaps we need an extension like tal:attributes="* attr_map", 
where every key/value pair in 'attr_map' becomes an attribute.

Cheers,

Evan @ Zope