Posted on : 27-01-2008 | By : Pawel Knapik | In : EN, web development
0
I’ve been playing with my JSTAL and Helma+CouchDB – and it seems to work really well!
Here’s a short Helma code example:
app.addRepository("modules/jstal/jstal.js");
app.addRepository("modules/helma/Http.js");
app.addRepository("modules/core/JSON.js");
global.dbData =
helma.Http().getUrl('http://localhost:5984/test/_all_docs')
.content.parseJSON();
var template =
<ul xmlns:tal="http://xml.zope.org/namespaces/tal">
<li tal:repeat="row dbData/rows">
<em tal:content="string: id = ${row/id}" />
</li>
</ul>;
res.write( jstal(template).render() )
Posted on : 26-01-2008 | By : Pawel Knapik | In : EN, web development
0
The recent Jaxer announcement makes me believe even more that JavaScript on the server may be The Next Big Thing this year.
I always wanted to use JS on the server, now there are many opportunities to do this. I have tried Helma and it feels great, but Jaxer has all that browser-related stuff like window object, DOM, CSS etc., so it may be the choice for front-end developers who want to start with server-side programming.
I used to write some PHP code before, and one of the best tools I used then was PHPTAL (implementation of Zope’s Template Attribute Language in PHP). I won’t elaborate why I like this template language (they did it), but it’s really really better than templates based on string replacing and concatenation (SMARTY, anyone?)
Some day I thought it would be great not only to use JS on the server, but add TAL template system to this toolbox, so I started to imlpement TAL specification in JS, using E4X (as I’m targetting mozilla-based environments).
My implementation isn’t complete yet, but I have started google project JSTAL – you’ll find more info on project wiki.
I don’t know if it works on Jaxer (because I’m waiting for Linux version), but it works well on other platforms that use Mozilla scripting engines (Helma, POW, Firefox2 and Rhino) so it should be OK. Please leave a comment if you gave it a try.
Here’s an example for you lucky Firefox 2 users: data and template code and rendering test, but remember that it’s meant to be used on the server, unless you target only Firefox users (or want to use it in a XUL Runner application).