Help Us Choose a Mozilla Markup Generation Solution

Monday December 03rd 2007, 2:56 pm Printer Friendly Version
Filed under:AllPeers, Software Development, Firefox
Posted By: Matt

UPDATE: Based on some discussion on IRC I probably should have given some more background to this post. In a nutshell, we are a Firefox extension and we store data in SQLite. For our extension’s user interface we want to generate markup (specifically HTML) from this data using templates that describe the page to generated, with placeholders for dynamic data. Something very similar to PHP, JSP, ASP, etc. in other words, but running on the client inside the Firefox process.


I’ve felt for some time that we need to change the way that AllPeers generates its user interface. For the most part, this is currently accomplished using a rather byzantine JavaScript-based framework loosely inspired by Eclipse. Experience has shown that this framework is a) rather slow, b) difficult for people to learn and understand and c) completely non-standard. At the same time, it’s proven challenging to find a viable alternative that meets all our requirements:

  • Minimal code footprint
  • Fast
  • Support for recursivity (iterating hierarchical structures)
  • Support for polymorphism (different template fragments for different types of data when iterating over a set)
  • Support for streaming generated markup
  • Execution possible in a background thread
  • Simple syntax conducive for working with graphic designers

The last point rules out XSLT, in my mind, since it’s too difficult to work effectively with a graphic designer who creates static HTML pages. How are such pages to be maintained once they have been broken up into lots of little template rules? So we took a close look at the various open source templating engines out there. There are some appealing options based on Python, but we decided that shipping the Python runtime with AllPeers is not realistic, which narrowed the choice down to two C++-based solutions: CTemplate and Clearsilver.

Then I read a recent blog post by Mark Finkle, prompting me to look again at an option that’s been kicking around in my head for ages: using XUL Templates. When I first investigated this a couple of years ago, they didn’t appear up to the task, but substantial improvements have been made since then. The ability to graft straight onto a SQLite database, in particular, is of great interest to us.

The main issue I see with XUL Templates is that we may want at some point to move AllPeers to its own process, leaving only a thin UI layer in Firefox. This implies that our future template engine will have to generate markup to a stream rather than manipulating a DOM directly. In addition, we may want to do this in two phases, initially running the generator in a protocol handler inside the Firefox process. So it has to work on a background thread. To my knowledge, XUL Templates currently can’t do either.

Do we go ahead and adapt an outside framework like Clearsilver for our purposes? Or do we try to soup up XUL Templates to meet our additional requirements. I’d love to opt for the latter since I think these improvements might be of value to the Mozilla community at large. But it’s a tough call without knowing the answers to the following questions:

  • Is anyone else out there interested in using XUL Templates to stream markup, run on a background thread, etc.?
  • How much work would it be to adapt the XUL Template engine to our requirements?
  • Is there a “third way” that I am missing?

Any input on either of these points would be greatly appreciated.


2 Comments »

  1. When you move AllPeers to it’s own process, how do you envisage the inter-process communication between it and Firefox working? Socket connection or something?

    Comment by enefekt — 12/3/2007 @ 4:40 pm

  2. FireBug has a good markup templating system called domplate.

    Comment by RichB — 12/4/2007 @ 9:03 am

Trackback URL RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

(required)

(required)