Clarity - ClearSilver templates in Zope 3 ========================================= This package, Clarity, integrates ClearSilver templates into Zope 3. Why? --- Zope 3 already has page template and even DTML, why would I want to use this? Some possible benefits ClearSilver brings are: * Absolute separation of logic from template. You cannot do complicated logic in a ClearSilver template, you can only extract data. You cannot call into the Zope 3 API *at all*. * Increased debuggability. Calling APIs is impossible from the template, which means that most bugs the API should appear in Python code already, where the programmer can worry about them, not the person who is tweaking the templates. While you are building a template you will *never* be bothered by, say, ComponentLookupErrors. * Increased testability. Since you know what HDF structure you expect to get in advance, you can test this using a normal unit test from Python code. Your template can stay simple. * Performance. Admittedly simplistic testing with 'siege' shows that for larger templates, ClearSilver templates integrated into Zope run several times faster than the equivalent ZPT page. However, since no significant codebases exist that use this facility, these benefits are somewhat speculative. More about ClearSilver here: http://www.clearsilver.net Installation ------------ You need ClearSilver and its Python bindings to install it. It's simple in Debian; just install python-clearsilver. For source downloads check here: http://www.clearsilver.net To install it, you need to place the 'src' directory on your PYTHONPATH somehow, and copy clarity-meta.zcml into your Zope's package-includes directory. Then restart Zope 3. Usage ----- To use it, use the browser:cspage directive. This behaves very similarly to the browser:page directive, except that it loads a ClearSilver page. To make it work, you need to use the 'class' statement on the cspage directive, and define a method 'hdf' on the class. This fills a hierarchical data structure with data that can be picked up by the ClearSilver template. For example:: def hdf(self): hdf = self.createHDF() hdf.setValue('foo.bar', 'Hello world') return hdf In the ClearSilver template you then say something like this::

Experimental TAL-like Clarity language -------------------------------------- See the README.txt in the 'xslt' directory for more details. License ------- BSD. See LICENSE.txt. ClearSilver itself has an open source license based on the Apache Software License v1.1.