XML/ HTML templates exist to separate logic from presentation in web services. This separation brings more than one accompanying benefit.
better application design
easier task repartition
better maintainability
easy web skins
Most template systems uses
<? ?>
,
<% %>
or
<xxx:yyy></xxx:yyy>
tags to find their sections. It allows easier template system development but doesn't really help template designers.
TAL hides most of its logic in XML attributes, preserving syntax and structure of XHTML. This allows previewing of TAL templates in web browser ( WYSIWYG editors, live previews) and doesn't break HTML syntax highlighting in programmers' editors.
If you have already worked with a simple template system, then you must have encountered something looking like:
<table><%loop myarray as myitem %><tr><td><% myitem %></td></tr><%/loop%></table>
Well, with PHPTAL you now can write:
<table><tr tal:repeat="myitem myarray"><td tal:content="myitem">
text replaced by the item value
</td><td tal:replace="">sample 1</td><td tal:replace="">sample 2</td><td tal:replace="">sample 3</td></tr></table>
The above code will render correctly with the sample text in normal web browser, so you can present it to your clients even if the code required to get '
myarray
' values doesn't yet exist.
Another big advantage of PHPTAL is that you benefit from more than 3 years of Zope community experience, documentation, examples, and help. PHPTAL relies on this community to provide its users a great deal of useful information.
PHPTAL is designed to be as customizable as possible for advanced developers and performance-eating systems, but still be easy to use for beginners, with a comfortable and simple default behavior (at least we tried :)