[ZPT] ZPT and plain-text or CSS

Evan Simpson evan@zope.com
Fri, 18 Jan 2002 12:55:10 -0500


Jon Edwards wrote:
> thread suggests it's possible to use ZPT in plain-text or CSS files, but I'm
> having trouble getting it to work!

You may be better off using DTML for text generation, although it is 
possible to use ZPT.

> I'm trying to setup a CSS stylesheet that can be edited either TTW (via a
> form that edits the PT's properties), or directly by Dreamweaver or similar
> (via WebDAV/FTP) - depending on a boolean property "ttw_style_editing" of
> the portal folder.

I don't understand this.

> background-color: <x tal:replace="template/bgcolor_setting"
> tal:condition="here/ttw_style_editing|default">#FFFFFF</x>

If the tal:condition evaluates false, the entire 'x' tag is omitted. 
Otherwise, the tag is replaced by the bgcolor_setting property.  I 
*think* you want:

tal:replace="python:test(path('here/ttw_style_editing|nothing'), 
template.bgcolor_setting, default)">#FFFFFF</x>

...which uses the property if 'here/ttw_style_editing' is true, and the 
default text '#FFFFFF' is the property is false or doesn't exist.

> 1. When I Browse HTML source, all the tal tags are still there. Is there any
> way to hide them so people pulling the .css with WebDAV/FTP won't see them?
> I tried the Omit-tag, but it doesn't seem to affect source?

That what the "source" in "Browse HTML source" means -- TAL source code. 
  Unless they are accessing the template through a WebDAV source port, 
people pulling the .css should get the rendered text.

> 3. If I change the Content-Type from text/html to text/css or text/plain I
> get an error -

That's because ZPTs with a non-"text/html" content type use XML rules 
instead of HTML rules.  Your template then needs to be well-formed XML, 
and you must have expat installed.

Cheers,

Evan @ Zope