ANN: Evoque - managed eval-based templating

mario ruggier mario at ruggier.org
Fri Mar 7 16:45:36 CET 2008


I'm proud to announce the first public release of the Evoque templating 
engine for python, version 0.1.

Evoque is a full-featured and generic text templating system for python 
using a simple $-substitution syntax and providing support for flow 
control, nested templates, overlays, inter-template addressing and 
invocation, cache management, arbitrary python expressions, advanced 
python % operator string formatting, restricted execution, automatic 
cross-site scripting protection, advanced encoding guessing algorithm, 
and more.

Allowing only python expressions and a managed evaluation namespace, 
Evoque offers a surprising level of simplicity, versatility and 
performance.

Buzz

     * Full-featured pure python templating engine / 970 SLOC
     * Automatic input quoting / XSS protection (thanks to Qpy)
     * Restricted execution
     * Every text file is a template
     * Unicode
     * Simplicity
     * Speed (+/- same as Mako)
     * Academic Free License v. 3.0

Template Syntax

     $ -> escape, replaced with $
     ${expr} -> substitution, like %(expr)s
     ${expr!format} -> substitution, like %(expr)format
     $if{expr} ... $elif{expr} ... $else ... $fi
     $for{item in items} ... $else ... $rof
     $begin{label} ... $end{label}
     $prefer{raw=False, data=None, quoting=None, filters=None}
     $evoque{name, src=None, collection=None, raw=False,
         quoting=None, input_encoding=None, filters=None, **kw}
     $overlay{name, space="positive", src=None, collection=None,
         raw=False, quoting=None, input_encoding=None, **kw}
     $test{**kw}
     #[ comment ]#
     "\" at end-of-line consumes the following newline

Usage

     domain = Domain("/home/user/templates")
     print domain.get_template("snap.html").evoque(vars())

Homepage

     http://evoque.gizmojo.org/

--
Mario Ruggier



More information about the Python-announce-list mailing list