About SimpleTAL

An introduction to SimpleTAL

What is SimpleTAL?

SimpleTAL is an independent implementation of the TAL and METAL languages.  TAL is the language used in Zope to power ZPT (Zope Page Templates), and is a nifty template language.  An example is worth a thousand words, so here's a simple example of a TAL template that demonstrates the simplicity and power of the language:


<html>
<body>
<h1 tal:content="title">
<h2 tal:condition="username">Welcome back <b tal:replace="username">Username here</b></h2>
<p>
Hot topics for today are:
<ul>
  <li tal:repeat="news hotItems">
  	<a tal:attributes="href news/link" tal:content="news/title">News item</a>
  </li>
</ul>
</p>
</body>
</html>

TAL does not allow you to send emails, access databases or write games - it is a pure templating language for laying out dynamic content in either a HTML or XML template.  SimpleTAL is written in Python, and so can be used by any Python program that wishes to generate HTML or XML.

The example above demonstrates most of what the TAL language can do:

  • Include content into an element (tal:content)
  • Replace an element (tal:replace)
  • Conditionally include part of a template (tal:condition)
  • Add attributes to an element (tal:attributes)
  • Repeat a piece of a template once for each entry in a list (tal:repeat)
  • Define variables (not shown - tal:define)
  • Conditionally omit tags (not shown - tal:omit-tag)

The TAL Guide provides details of how to use TAL.  There are examples of how to use SimpleTAL included in the download, as well on my example page.  Additionally, I've documented the API to SimpleTAL, and written some notes which document the differences between SimpleTAL and the Zope implementation.

A brief history

SimpleTAL was written because I wanted to be able to use the TAL language in my weblog software, and I didn't want to have to install or use the full Zope system to do this.  Since then SimpleTAL has slowly evolved, improving in speed, number of test cases and features.

Since the version 4.0 release in 2005 the library has proved to be very stable, with only a small number of defects and enhancements made since then.  The latest release series (5.x) brings SimpleTAL to Python 3.

Return to SimpleTAL

Last Modified: Sun, 01 Feb 2015 10:59:33 CET

Made with PubTal 3.5

Copyright 2021 Colin Stewart

Email: colin at owlfish.com