SubtleTemplates for MooTools
Thomas Aylott has been busy on some nice functionality that helps you drive dynamic content through templates and keep them updated in the DOM whenever their relevant data changes. Check it out in the git-hub repo. Very slick:
The main branch is very stable, but I’m working on some extra awesomeness in the other branches too.
Basically, you create a template in html, make a new template and pass in that element, take a javascript object, like the result of a Request.JSON and then pass it into a new template and it’ll use String#substitute to populate the template using the object.
It sounds simple, but it’s blazingly fast, well tested and feature packed. You can repopulate an existing template instance with a new object. You can modify the template on the fly and all the instances will magically update and repopulate themselves in place, etc… It’s very powerful. I’m also using it in production at GreenSherpa.com
The Multi branch adds some experimental support for populating a whole bunch of template instances using an array of objects.
The SubTemplates branch adds some experimental support for nested templates and populating with nested objects. Imagine the result of a search which has some data about the search itself as well as an array of results.
You can download and play with the demos from the repository, but just glancing at the source of the demo page will illustrate the usage quite clearly.
Follow @clientcide on twitter to get notified of new posts.
To follow me personally on twitter, follow @anutron.
January 28th, 2009 at 3:18 pm
I wrote my own template system for JS, which looks completely like the one in Typo3, but I’m really not satisfied with it in any way. This might be a nice replacement for it, if only I had the time to test it out.