beauty in the details, evoque’s unique features

For the exquisite pleasure of all of you who appreciate the many
little details that make up a beautiful design,
here are just some of unique qualities of Evoque
that bubble up to user visibility as a feature
in some big or small way.

Note that this is a sampler only of features
that are exclusive and unique to Evoque i.e.
not any of the big and important Evoque features
that probably every other templating engine should also have
[a]
even if surprisingly few actually do e.g.
sandbox, complete unicode, automatic escaping.

In some cases, contrasting a feature with how other
templating system might support it
helps to better appreciate the feature or its intention —
for these cases, we pay honour to the extremely capable
Mako 0.2.4
that amongst text templating systems is probably the
most comparable to Evoque.

small yet ultra-capable

One indication of size is the SLOC count
— for Evoque the installed runtime package
is made up of 992 SLOC, while for
Mako 0.2.4 it is 3552 SLOC
[b].

Another indication of size is the number of
keywords. Evoque collectively calls
these directives
and defines 7 of them. By contrast, Mako
calls these
control structures
and
tags
and defines a total of 11 of them.
Yet, as far as capability is concerned,
there is in practice nothing that can be done with Mako’s 11
constructs that may not be done with Evoque’s 7 directives.
The opposite seems to not be true however
e.g. there seems to be no Mako equivalent to
Evoque’s test directive.

Beyond the template constructs, that same small number of SLOC
also offers other major capabilities
(e.g. sandbox support, all the other unique features below)
that Mako and other systems do not offer.

Small is of course naturally accompanied by simple,
easy to remember, easy to use.

automatic once-only escaping for any output format

Evoque is constructed on the quoted-no-more
string type pattern, and a string type to take care
of automatic once-only quoting of xml/html output
is provided by default. An application may extend this behaviour
to any output format by adding
custom
quoted-no-more classes
.

clean template inheritance

An Evoque template needs no modifications to be used as a base template
i.e. a base template is perfectly functional and usable as a template
in its own right, just as well as any template that inherits from it
(called an overlay in Evoque parlance).
In contrast, super and sub templates in Mako must make explicit
inheritance-specific calls e.g.
next(),
body() and
parent()
possibly making them unusable outside of the inheritance chain,
as well as causing problems in cases when we need to inherit from a
template for which we do not have write permission.

positive and negative template space

Unique to Evoque is the concept of
positive and negative
template space and an inheriting template,
or overlay,
may choose to override either one or the other.

line-agnostic control structures

All controls structures and directives may be
specified liberally over single or multiple lines.
This has benefits such as allowing an inlined
if/elif/else or an inlined for loop
(or even a combination of the two)
to calculate for example the value of an HTML attribute,
just as easily as multi-line
if/elif/else or for blocks to control
which section of a template gets rendered.
Evoque makes no assumptions about whether a directive
(or combination of directives)
should occupy an entire line, be part of a line, or span several lines —
such constraints belong exclusively to the targeted output format.

one syntax

Evoque logic in templates is specified with directives and expressions.
Syntactically these are the same — the only difference is that a directive
has an additional qualifying keyword between the initial
$ and the opening { or {% delimiter
— making the syntax consistent and easy to remember.
In contrast, Mako has a different syntax for each type of construct:
– control structures: % if x==5:\n,
– tags: <%inherit>,
– code blocks: <% return %>,
– expressions: ${x}.

conditional decorators

An open-ended mechanism to conditionally intercept input and/or
output of any directive or expression and do something with it —
but with the possibility of turning it on and off depending on the context.
The syntax is consistent for both directives and expressions:
$directive[ condition ? decorator(*args) ]{ ... }

$[ condition ? decorator(*args) ]{ ... }

and when condition evaluates to True,
the evaluation of the directive/expression is decorated,
while when condition evaluates to False
the decorator is compiled out of the loaded template,
thus rendering performance is categorically not affected.
Use cases include expression/block level output caching,
validation, etc.
Not yet available.

template auto tests

A template may declare multiple
test data scenarios
that it should be able to handle.

all python % operator expression formatting

Expressions may take advantage of
all formatting options
allowed by python’s
string formating operations.

nested comments

Surprisingly rare!
Nested comments are very convenient,
in particular during development,
for commenting out entire blocks of template source
that may contain other comments.

nicer to the file-system

Evoque’s template caching
supports an auto_reload:int=60 parameter
to set the minimum number of seconds to wait between
file-system checks — other template systems typically just
offer a flag whether to do the file-system check or not,
on each request.

not inappropriately pythonic

Some template engines pride themselves with being pythonic,
to the extent of even imposing such pythonicities as
template source indentation! Evoque leaves how template
source code should be formatted entirely to the liberty
of the target output format. If you want your templates to look
really pythonic, it is easy enough to write python directly,
or to use a slightly modified more convenient python syntax such as
that offered by
Qpy Templates.

no implementation clutter

Usage of evoque is not cluttered by underlying implementation details
i.e. you do not need to be aware of any runtime implementation details.
This is in contrast to other systems that sometimes require you to
explicitly workaround some internal detail.
For example, to maximize performance Mako plays some tricks with its
internal buffering, requiring you in some cases to specify things like
buffered="True" to get the output you expect.
Actually, generated output in Evoque is internally always buffered,
with the
performance being none the less than Mako’s.

Python 3.0

Since version 0.4
released on 21 January 2009
the same Evoque code base runs also on Python 3.0,
probably making Evoque the first full-featured templating engine
to be available for Python 3.0.

[a] Roland Koebler identifies such
a list of bread and butter features
that every templating engine should have.

[b] Source Lines of Code (SLOC) are counted with
SLOCCount.