Benji York wrote:

Martijn Faassen wrote:

Right, that was my motivation too - I googled around for javascript-based templating languages but realized there wasn't really anything. Of course XSLT can be used this way too, but TAL is kinda neat too. Still, I couldn't think of much practical use for this. Perhaps in this AJAXy world this has changed.


Personally I'm very excited about ctal (and like the name too). Getting data objects from the server and feeding them to templates on the client seems like a nice way to do AJAXy things.


yep, you can also use TAL (ZPT) to create CTAL templates; that's the reason why I think the namespace is ctal:... and not tal:..., otherwise it could as well have been called tal:... and the template be stored in a string.

then there are different usage patterns,
personally I download the template from the server when the page is getting initialized (using asynchronous Ajax.request) and I store the source in a javascript variable in a widget class. To render the template I apply the transformation whenever the data changes. It makes it possible to refresh widgets, otherwise you'd have to refresh the page or redo an Ajax.request.

here is the part of the code that does the rendering:

render: function(data) {
 if (this.source) {
   var node = document.createElement("div");
   node.innerHTML = this.source;
   ctal.process_ctal(node, data);
   var old_html = this.widget.innerHTML;
   var new_html = node.innerHTML;
   if (new_html != old_html) {
     this.widget.innerHTML = node.innerHTML;
   }
 }
}

the performance is quite fine actually, but since this is event-driven I should first check that the data really has been changed before firing a "modified" event, to avoid rendering the template for nothing.

I think 'ctal' is fine too. (client tal)

/JM
_______________________________________________
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to