jQote2 is the second major release of jQuery’s most powerful and versatile client-side templating engine. Version 2 now incorporates a faster and more accurate parsing/conversion part that does away with its predecessor’s shortcomings in escaping quotes and multiline support.
If you haven’t used or never heard of jQote before you might want to check out this post first, as it provides a quick insight into jQote’s way of client-side templating.
I’ve set up a repository over at GitHub. That’s where you will find the latest releases.
So, what’s new for v2 you ask? Quite a lot, actually. But let’s see one by one:
1. jQote2 breaks compatibility with its predecessor
- jQote2 now returns a flat string representation of the converted template whereas its predecessor would give you a jQuery object.
The reason behind this substantial change is mainly speed. Appending the converted string as a whole cuts back greatly on the time it takes to generate the corresponding DOM fragment. On top of that you’ll now gain full control over your template’s outcome, to whom and when you want it to be appended etc.
2. jQote2 improves on template handling
- jQote2 now provides an interface to precompile your templates to lambda functions.
This is probably the most exiting new feature as it lets you precompile templates during development and simply use them in production afterwards – without the need to dish out your template code to your customers.
- jQote2 now supports on-the-fly template strings.
For quick and dirty templating jQote2 now enables you to process template strings. This will make it easy for you to realize minor templating tasks on-the-fly without added the overhead.
3. jQote2 is powered by a faster and more robust parsing engine
- jQote2 now offers full multiline and escaping quotes support.
- Speed, speed and again – speed!
To backup my claims I forked Brian Landau’s benchmarks and put together a single file benchmarking suite at github. To offer you some eye candy I’ve integrated the powerful flot plotting library. Here’s an example of my findings running the benchmark 25 times with a 1000 conversions each in Firefox 3.5.7.
From left to right: Srender, mustache.js, Underscore, jQote2, Tempest, nano.
Less is better. All times in ms.
Enough said! Try it for yourself. Due to repeated requests I have finally set up a repository over at github. You may fetch the latest versions there. So long …