[Helma-dev] Javascript Template Engine
Hannes Wallnoefer
hannesw at gmail.com
Thu Jun 22 12:34:00 CEST 2006
Hi list,
as some of you may already have heard through jabber and street talk,
I'm proposing to use Jürg's JavaScript template engine as a starting
point implementation for Helma 2 skins/templates.
http://dev.helma.org/Wiki/JavaScript+Template+Engine/
Here a short list of my reasons to like Jürg's engine:
* JavaScript is the natural language/level to implement this.
Invocation of macros/functions, and getting properties is usually
simpler from JS than from Java.
* Jürg's engine already implements Helma 1 macros pretty well, which
is a requirement for Helma 2.
* Advanced features such as foreach, if/else etc are implemented
separately from macros, which makes it pretty simple to disable them
and offer different feature sets to different sets of users.
* The direct, stack-less translation into a JS function is quite smart.
And here's a set of things that are still missing, IMO:
* Security. I think each time we do an eval(), we need to be
absolutely sure that it's safe. The JSON JavaScript implementation
shows that this is possible[1], and I think JSON recommends itself for
use in complex macro parameter support.
* Related to the first point, I think it might be worth to consider
implementing some skin/template/macro parsing in Java. I'm not sure
about this. The current implementation works well with proper template
syntax, but for broken/bad intentioned templates, I think it might be
better to catch it in a dedicated parser than with eval()
[1] http://dev.helma.org/Wiki/JavaScript+Template+Engine/ (regexps
at the bottom before the eval())
Please let me know what you think.
hannes
More information about the Helma-dev
mailing list