Hello,

I've just joined this list today having stumbled across Velocity on one
of my regular strolls through the Apache site and I'm immediately
gripped by the possibility of cross polinating it with our template
engine which we call Takhini.

Velocity and Takhini seem to have a great deal in common, but the
differences are interesting too.

Some background. We designed Takhini as a template engine that can be
used to parameterise textual content including HTML, emails, XML,
Postscript whatever. It's current status is "unreleased open source" by
which I mean that we intend to open source it and have always intended
to do so, but haven't yet decided that it's ready for the attentions of
the wider development community. I know it's not exactly "release early,
release often", but what I'm afraid that's where we're at just now.

We regard Takhini as an expression evaluator with the whole template as
an expression. Templates are evaluated against an "evaluation context"
which is an aggregation of Java objects that provide variables and
functions. A trivial example would be

 My name is %user.name%; what's yours?

which when evaluated in a context that provided a value of "Andy
Armstrong" for the variable user.name would turn into

 My name is Andy Armstrong; what's yours?

Objects that form part of the evaluation context can also provide their
own functions.

Lists are treated specially in Takhini. Consider these mappings

 1 + 2                            --> 3
 "Hello, " + "World"              --> "Hello, World"
 "Hello, " + ["World", "Chums"]   --> ["Hello, World", "Hello, Chums"]
 [1, 2, 3] + [5, 5, 5]            --> [6, 7, 8]

(it may be apparent that list literals are enclosed in square brackets).

Takhini loops automatically iterate over list values that are evaluated
within them, so

 %.list=["Tic","Tac","Toe"]%
 %{%
    Cedric says %list%
 %}%

would expand to

    Cedric says Tic
    Cedric says Tac
    Cedric says Toe

and could have been written as

 %{%
    Cedric says %["Tic","Tac","Toe"]%
 %}%

In other areas Takhini is very similar to Velocity -- I won't bore
everyone by enumerating those similarities.

The Takhini parser is currently hand coded -- no particular reason; I
just prefer (enjoy even) writing parsers from scratch.

I anyone's interested I can point you at a more formal syntax for the
language.

Bye.

-- 
Andy Armstrong, Tagish

Reply via email to