Why use PHPTAL


XML/HTML templates exist to separate logic from presentation in web services. This separation brings more than one accompanying benefit.

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.

The idea behind TAL is to allow WYSIWYG template editing with sample rendering without strange tags everywhere. That's why TAL works on XML attributes instead of markup tags.

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>

In WYSIWYG mode, the above code will render correctly with the sample text, and 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 behaviour (at least I tried :)