If you use Cheetah, please support the project and register by
clicking here:

C..6 Cheetah vs. PHP's Smarty templates

PHP (http://www.php.net/) is one of the few scripting languages
expressly designed for web servlets. However, it's also a full-fledged
programming language with libraries similar to Python's and Perl's. The
syntax and functions are like a cross between Perl and C plus some original
ideas (e.g.; a single array type serves as both a list and a dictionary,
$arr[]="value"; appends to an array).

Smarty (http://smarty.php.net/) is an advanced template engine for
PHP. (Note: this comparision is based on Smarty's on-line documentation.
The author has not used Smarty. Please send corrections or ommissions to the
Cheetah mailing list.) Like Cheetah, Smarty:

compiles to the target programming language (PHP).

has configurable delimeters.

passes if-blocks directly to PHP, so you can use any PHP expression in
them.

allows you to embed PHP code in a template.

has a caching framework (although it works quite differently).

can read the template definition from any arbitrary source.

Features Smarty has that Cheetah lacks:

Preprocessors, postprocessors and output filters. You can emulate a
preprocessor in Cheetah by running your template definition through a filter
program or function before Cheetah sees it. To emulate a postprocessor, run a
.py template module through a filter program/function. To emulate a Smarty
output filter, run the template output through a filter program/function. If
you want to use ``cheetah compile'' or ``cheetah fill'' in a pipeline, use
- as the input file name and --stdout to send the result to
standard output. Note that Cheetah uses the term ``output filter'' differently
than Smarty: Cheetah output filters (#filter) operate on placeholders,
while Smarty output filters operate on the entire template output. There has
been a proposed #sed directive that would operate on the entire output
line by line, but it has not been implemented.

Variable modifiers. In some cases, Python has equivalent string
methods (.strip, .capitalize, .replace(SEARCH, REPL)),
but in other cases you must wrap the result in a function call or write
a custom output filter (#filter).

Certain web-specific functions, which can be emulated with
third-party functions.

The ability to ``plug in'' new directives in a modular way. Cheetah
directives are tightly bound to the compiler. However, third-party
functions can be freely imported and called from placeholders, and
methods can be mixed in via #extends. Part of this is
because Cheetah distinguishes between functions and directives, while
Smarty treats them all as ``functions''. Cheetah's design does not
allow functions to have flow control effect outside the function
(e.g., #if and #for, which operate on template body lines),
so directives like these cannot be encoded as functions.

Configuration variables read from an .ini-style file. The
Cheetah.SettingsManager module can parse such a file, but you'd
have to invoke it manually. (See the docstrings in the module for
details.) In Smarty, this feature is used for
multilingual applications. In Cheetah, the developers maintain that everybody
has their own preferred way to do this (such as using Python's gettext
module), and it's not worth blessing one particular strategy in Cheetah since
it's easy enough to integrate third-party code around the template, or to add
the resulting values to the searchList.

Features Cheetah has that Smarty lacks:

Saving the compilation result in a Python (PHP) module for quick
reading later.

Caching individual placeholders or portions of a template. Smarty
caches only the entire template output as a unit.

Comparisions of various Smarty constructs:

{assign var="name" value="Bob"} (#set has better syntax in the author's opinion)
counter (looks like equivalent to #for)
eval (same as #include with variable)
fetch: insert file content into output (#include raw)
fetch: insert URL content into output (no euqivalent, user can write
function calling urllib, call as $fetchURL('URL') )
fetch: read file into variable (no equivalent, user can write function
based on the 'open/file' builtin, or on .getFileContents() in
Template.)
fetch: read URL content into variable (no equivalent, use above
function and call as: #set $var = $fetchURL('URL')
html_options: output an HTML option list (no equivalent, user can
write custom function. Maybe FunFormKit can help.)
html_select_date: output three dropdown controls to specify a date
(no equivalent, user can write custom function)
html_select_time: output four dropdown controls to specify a time
(no equvalent, user can write custom function)
math: eval calculation and output result (same as #echo)
math: eval calculation and assign to variable (same as #set)
popup_init: library for popup windows (no equivalent, user can write
custom method outputting Javascript)
Other commands:
capture (no equivalent, collects output into variable. A Python
program would create a StringIO instance, set sys.stdout to
it temporarily, print the output, set sys.stdout back, then use
.getvalue() to get the result.)
config_load (roughly analagous to #settings, which was removed
from Cheetah. Use Cheetah.SettingsManager manually or write
a custom function.)
include (same as #include, but can include into variable.
Variables are apparently shared between parent and child.)
include_php: include a PHP script (e.g., functions)
(use #extends or #import instead)
insert (same as #include not in a #cache region)
{ldelim}{rdelim} (escape literal $ and # with a backslash,
use #compiler-settings to change the delimeters)
literal (#raw)
php (``

Some of these modifiers could be added to the super output filter we
want to write someday.