Shane O'Sullivan's technical blog… really ties the room together

Archive for the ‘templating’ Category

Dojo’s new Mobile App Project

Posted by Shane O'Sullivan on June 13, 2010

Dojo v1.5, which should be released in the coming weeks, will contain an early beta of a new infrastructure for building Mobile Apps.  Currently it is called, but that is expected to change.  Check out the test apps (the bottom section) at , which work best in WebKit, so use Safari or Chrome for best results.

Jared Jurkiewicz and Yoshiroh Kamiyama recently added the project.  It provides some very nice widgets for use on mobile phones, such as views that can transition between each other, rounded lists, tab containers etc.

However, the focus of is to be very small, so as to suit websites formatted for mobile devices.  When writing cross device apps that are hosted on a phone, the size of the JavaScript is less of a concern, so a much more powerful experience can be created.

Hence, is born.

It is built on top of, but adds many new features, with more on the way.

  • Templated views that can be pushed and popped off the stack of views, all of which are lazily loaded.
  • Templated lists
  • Input widgets
  • Image Gallery
  • Dialog Boxes
  • Popup Menus

are all available now.  The structure of a application is modeled very closely to a webOS app.  The templates and code are in a similar folder structure, and the lifecycle for creating and destroying (popping) scenes/views are very similar.

The goal of is NOT to replace or duplicate the functionality in PhoneGap.  PhoneGap provides low level access to many phone features. aims to provide an easy to use, flexible application structure, and many widgets that you will find useful, all themed to appear native to each platform.  In a real world app, it would make most sense to use both PhoneGap and

One of the cooler widgets currently available is the ImageView widget, check it out at .  Some of its features include

  • Canvas based
  • Touch capable
  • Swipe across to change images
  • Tap to zoom in, and then swipe to move around an image
  • Progressive loading of images – first load a small version of an image, and later a larger version is currently tested mostly on the iPhone, but will soon support webOS and Android also.  The mobile world is an exciting place to be right now, and Dojo is jumping in feet first 😉

Posted in Ajax, demo, dojox, Flickr, Image Gallery, Javascript, mobile, open source, Palm, Technical, templating, WebOS | 7 Comments »

Quick Django Tip – Modulus

Posted by Shane O'Sullivan on September 27, 2008

I was fiddling around with Dojo‘s Django Templating language (amazingly cool bit of tech of course), and got a bit stuck trying to do something very simple: modulus

All I wanted to do was stripe a list of elements by applying a different class based on whether a row was odd or even. It turns out the reason the answer didn’t really pop up in searches was because, in Django land, it is called divisibleby

So, if you are using a for loop in Django, to check if
(current loop index % 2) == 0
you can use

which returns either true or false.

Posted in django, dojox, Javascript, Technical, templating | 9 Comments »

Dojo’s DTL performance gains with HtmlTemplate

Posted by Shane O'Sullivan on August 25, 2008

I’ve recently discovered (and greatly appreciated) the performance gain to be found with switching to using Dojo‘s Django Templating Language’s HtmlTemplate class.

I was previously using the standard dojox.dtl.Template class, which writes textual HTML, and sets the innerHTML property of a node.  While this worked relatively well on Firefox and Safari, on IE 6 and 7, it performed like a snail, mostly due to IE’s terrible DOM performance.

Neil Roberts has written a DOM-based template generator for Dojo 1.2 (currently in the nightlies) that solves this nicely.  Instead of writing to the innerHTML of a DOM node, and overwriting the template each time, it generates the nodes just once, and reuses them each time.

For repeated operations, the speed up is amazing – I found that it generated large templates up to four times faster in Internet Explorer, with smaller gains in more up to date browsers like FireFox and Safari.

It also greatly reduces the chances of memory leaks – which are a real problem if you are dealing with innerHTML.

I’ve updated my search site,, with Neil’s latest code, and it’s running much quicker than before.  Neil has also updated his blog,, with the latest code.

Hopefully with the release of Dojo 1.2 (any day now….), Neil should have a good amound of docs and demos to show people how to get the most out of dojox.dtl – it really is a fantastic piece of software.

Posted in Ajax, django, Dojo, dojox, Javascript, open source, templating | Leave a Comment »

%d bloggers like this: