Separation of content and code for web (was Re: Python for web ?)

Evan Simpson evan at 4-am.com
Mon Dec 1 20:54:59 CET 2003


Rene Pijlman wrote:
>>Anyone know of a Python-based approach using the same core concept?
> 
> ZPT: http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/ZPT.stx

Not really the same as what Peter is talking about, since we use 
embedded element attributes.  I *do* plan an extension to ZPT, called 
TERSE, that will be to TAL as CSS stylesheets are to style attributes. 
This will allow you to take a pure-HTML/XML document and modify it with 
external rules such as:

// Plug the template's Dublin Core title into the title element
title { content: template/dc:title; }

// Put data into a table
tr#students { repeat: student in students; }
tr#students td { search-replace: student delimited '#(' ')#'; }

// Attach error text and markup to form fields
form .field {
   // Get the field name from the name attribute
   fn = [name];
   // Get the error text, if any.
   err = errors/var:fn | nothing;
   @if(err) {
     // Add 'error' to the class attribute.
     [class] += ' error';
     // Insert the error message at the end of the field element
     content-after: structure "<span class="error-popup">$err</span>";
   }
}

Syntax subject to change, probably a lot.

Cheers,

Evan @ 4-am







More information about the Python-list mailing list