Feature highlights
- Full-featured generic templating engine, with rich features such as overlays and template caching.
- Small footprint, coming in at 957 SLOC. And 145 of those SLOC are consumed by the generic and fairly advanced algorithm for guessing a string's encoding (see a separate discussion of the decodeh module). On the other hand this number does not include the code for the unit tests or the benchmarks.
- Unicode. All internal processing is done on unicode instances. To facilitate this Evoque includes a sophisticated encoding guessing algorithm. Any and all encoding of the output is left to the liberty of the client application.
- Template addressing. Every template, nested or not, is evoque'able from within any other.
- Conditionals, loops, nested templates, evoque'ations, comments may all be liberally intermixed and nested.
- Automatic input quoting / XSS protection thanks to the h8 quoted-string class from the Qpy Templating package, providing automatic cross-site scripting protection by guaranteeing that all input is always quoted and quoted only once. To benefit from this feature Qpy needs to be installed -- running without Qpy only means that you must take care to do your input quoting manually (which is only precisely what most other text templating systems require you to do). But, if you want to Avoid Being Called a Bozo When Producing XML, then this is one killer feature that you want!
- Python expressions only, i.e. no python statements, nothing is ever exec'ed.
- Restricted execution. Evaluation is within a managed, and optionally restricted, namespace; templates may be safely exposed to untrusted clients.
- Easily introspectable templates, of their signatures and evaluation namespace.
- Good error handling making template development and debugging easy.
- Applications may extend evaluation namespace with any python callable or in particular with Qpy Templates.
- Every text file is a template. No particular distinction between template and content, i.e. any text source when used as one, is a template. Useful to assemble and evoque bits and pieces of content.
- Simplicity, with a trivially memorable syntax, just a handful of directives, easy management of different template collections, and general consistency.
- Speed. The simplicity of the implementation, and the awesome python builtins and standard library, translate into what may well be the fastest pure python templating system around.
Notes on the design and philosophy
- Templates are organized in Collections that belong to a Domain.
- Collections have a root folder -- all text files below are templates.
- All collections are explicitly named -- decouples template addressing from deployment paths and protects sensitive path info within templates.
- The creation of the Domain also creates the default Collection, that is named "" (the empty string). The default collection may be given another name, by simply creating it first.
- Every template instance is associated to one and only one collection.
- All templates are assigned a nick name, unique within the collection: memory-based templates are always named explicitly; for file-based templates the default name is their collection-root-relative or c-rel locator.
- The location of any collection-qualified template (from application code or from within templates) is always specified as c-rel.
- A previously loaded template may be retrieved by its name and (if caller is application code or a template from another collection) the collection.
- The eval globals dict belongs to Evoque and/or the Client Application, and is shared by all templates in a domain -- it is never modified after initialization.
- The eval locals dict belongs to the document being rendered, and is passed down the nested execution scope, possibly cloned and modified each time.
Del.icio.us