From: Conrad Schneiker Date: 2001-03-23T15:47:53+09:00 Subject: [ruby-talk:13117] ZPT, a next-generation template technology (repost) FYI. Thought some Rubies might be interested in this. Subject: ZPT, a next-generation template technology Date: Sat, 17 Mar 2001 01:43:50 -0000 From: "Hamish Lawson" Newsgroups: alt.php, comp.lang.java, comp.lang.perl.misc, comp.lang.python Hamish Lawson wrote: > > The Zope Presentation Templates project is underway at Digital Creations > to develop a next-generation template technology for Zope* that is > XHTML-compliant and which makes it easier for designers to work with. > However it is hoped to design it in such a way that as much as possible > is not specific to Zope, in the belief that the technology is more > widely useful and could be adopted by other languages and tools. > Developers from other communities may want to consider contributing to > the design of ZPT to help keep it language-independent, and to consider > implementing the approach in their programming language of choice. > > First of all some background on what is meant by "next-generation". > > In the beginning programmers wrote program code with embedded HTML. Then > technologies like eperl, ASP, PHP and JSP allowed us to reverse this and > to embed program code in the HTML. However a school of thought wanted to > have greater separation of presentation and logic, and so various > template mechanisms were devised that provided just enough > programmability to control presentation, but which moved the business > logic out elsewhere. One example of this approach is Freemarker: > >

$customername

> > > > > > > > > > > >
DateAmount
${deposit.date}${deposit.amount}
> > Instead of custom tags some other template mechanisms use special > markers to designate control structures, but in general most template > mechanisms share the property that their templates are not compliant > with XHTML (though the rendered output may be). As such it can be > awkward trying to use such template mechanisms with authoring tools that > only understand XHTML. > > The approach that the ZPT project is pursuing is to attach the control- > flow, formatting and placeholder directives as *attributes* of standard > XHTML tags. The example above thus becomes something like: > >

Bob Smith

> > > > > > > > > >
DateAmount
01/02/200123.40
> > Because this doesn't make use of special tags, but employs attributes > instead, it should pass unscathed through most decent authoring tools. > Moreover (borrowing an idea from Enhydra's XMLC template scheme) the ZPT > template scheme allows typical sample content to be used as a proxy for > the real data (which is substituted by the template engine), so making > it easier to work with in an authoring tool. > > More information on the rationale of attribute languages can be found > > http://dev.zope.org/Wikis/DevSite/Projects/ZPT/AttributeLanguage > > An overview of ZPT can be found at > > http://www.zope.org/Wikis/DevSite/Projects/ZPT/VisionStatement > > Hamish Lawson > > * Zope is a leading open-source web application server and content- > management framework, written in Python by Digital Creations. Conrad Schneiker (This note is unofficial and subject to improvement without notice.)