<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>once upon my code &#187; jQuery plugins</title>
	<atom:link href="http://aefxx.com/category/jquery-plugins/feed/" rel="self" type="application/rss+xml" />
	<link>http://aefxx.com</link>
	<description></description>
	<lastBuildDate>Thu, 19 Jan 2012 18:40:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>jQote2 &#8211; Javascript templating revamped</title>
		<link>http://aefxx.com/jquery-plugins/jqote2/</link>
		<comments>http://aefxx.com/jquery-plugins/jqote2/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 21:39:16 +0000</pubDate>
		<dc:creator>aefxx</dc:creator>
				<category><![CDATA[jQuery plugins]]></category>

		<guid isPermaLink="false">http://aefxx.com/?p=272</guid>
		<description><![CDATA[jQote2 is the second major release of jQuery&#8217;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&#8217;s shortcomings in escaping quotes and multiline support.
If you haven&#8217;t used or never heard of jQote before you might want to check out this [...]]]></description>
			<content:encoded><![CDATA[<p><em>jQote2</em> is the second major release of jQuery&#8217;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&#8217;s shortcomings in escaping quotes and multiline support.</p>
<p><span id="more-272"></span><span class="grey">If you haven&#8217;t used or never heard of jQote before you might want to check out <a href="http://aefxx.com/jquery-plugins/jqote">this post</a> first, as it provides a quick insight into jQote&#8217;s way of client-side templating.</span></p>
<p>I&#8217;ve set up a <a href="http://github.com/aefxx/jQote2">repository over at GitHub</a>. That&#8217;s where you will find the latest releases.</p>
<p>So, what&#8217;s new for v2 you ask? Quite a lot, actually. But let&#8217;s see one by one:</p>
<p><strong>1.  jQote2 breaks compatibility with its predecessor</strong></p>
<p>- <em>jQote2 now returns a flat string representation of the converted template whereas its predecessor would give you a jQuery object.</em></p>
<p>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&#8217;ll now gain full control over your template&#8217;s outcome, to whom and when you want it to be appended etc.</p>
<p><strong>2.  jQote2 improves on template handling</strong></p>
<p>- <em>jQote2 now provides an interface to precompile your templates to lambda functions.</em></p>
<p>This is probably the most exiting new feature as it lets you precompile templates during development and simply use them in production afterwards &#8211; without the need to dish out your template code to your customers.</p>
<p>- <em>jQote2 now supports on-the-fly template strings.</em></p>
<p>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.</p>
<p><strong>3.  jQote2 is powered by a faster and more robust parsing engine</strong></p>
<p>- <em>jQote2 now offers full multiline and escaping quotes support.</em></p>
<p>The previous version had issues regarding line breaks within the scope of shorttags which are used to echo out the result of Javascript expressions. jQote2 now fully supports your way of coding style: what goes inbetween the tags (be it shorttags or standard notation) is pure Javascript and you decide how it is layed out.</p>
<p>Pure Javascript support implies proper escaping of quotes, though. And you will have to take care of that yourself. Outside the tags however the engine now correctly escapes qoutes within your markup, thus letting you concentrate on your work rather than the plugin&#8217;s internals.</p>
<p>- <em>Speed, speed and again &#8211; speed!</em></p>
<p><a href="http://www.viget.com/extend/benchmarking-javascript-templating-libraries/">Brian Landau</a> has set up a bunch of benchmarks comparing the runtime of Javascript templating libraries. jQote didn&#8217;t perform all that bad but in the end couldn&#8217;t gain the crown.</p>
<p>With the release of jQote2 though the picture has changed quite a bit: jQote2 is now on a par with <a href="http://github.com/documentcloud/underscore/">Underscore</a>, the former sole sovereign, making both the natural choice for heavy Ajax powered sites. Please note though: Since Underscore internally uses John Resig&#8217;s conversion engine it replicates its flawed multiline and escaping quotes handling, leaving you with runtime errors whenever you need to have single quotes (both escaped or unescaped) inside the Javascript parts.</p>
<p>To backup my claims I forked Brian Landau&#8217;s benchmarks and put together a single file benchmarking suite at github. To offer you some eye candy I&#8217;ve integrated the powerful <a href="http://code.google.com/p/flot/">flot plotting library</a>. Here&#8217;s an example of my findings running the benchmark 25 times with a 1000 conversions each in Firefox 3.5.7.</p>
<p><a title="jQote2 benchmarking suite" href="http://aefxx.com/wp-content/uploads/2010/03/jqote.benchmarks.png"><img style="border: 0pt none; margin: 0;" title="jqote.benchmarks" src="http://aefxx.com/wp-content/uploads/2010/03/jqote.benchmarks.png" alt="jqote2 benchmarking suite" width="480" height="212" /></a>
<p class="grey">From left to right: Srender, mustache.js, Underscore, jQote2, Tempest, nano.<br/>Less is better.  All times in ms.</p>
<p>As you see Underscore and jQote2 vastly outperform the other contestants and moreover are superior in their ability to embed pure Javascript within the templates.</p>
<p>Enough said! Try it for yourself. Due to repeated requests I have finally set up a <a href="http://github.com/aefxx/jQote2">repository over at github</a>. You may fetch the latest versions there. So long &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://aefxx.com/jquery-plugins/jqote2/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>jQote &#8211; client-side templating</title>
		<link>http://aefxx.com/jquery-plugins/jqote/</link>
		<comments>http://aefxx.com/jquery-plugins/jqote/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 17:52:10 +0000</pubDate>
		<dc:creator>aefxx</dc:creator>
				<category><![CDATA[jQuery plugins]]></category>
		<category><![CDATA[jQote]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://onceupon.com/?p=47</guid>
		<description><![CDATA[PLEASE NOTE:
jQote2 has been released. Please consider upgrading now!!! Click here for a quick summary of what&#8217;s new and what&#8217;s changed.
jQote (pronounced like Star Trek&#8217;s Chakotey) is basically a rewrite of John Resig&#8217;s awesome JavaScript Micro-Templating utility. I took his code and ported it to jQuery, overhauled the parsing / conversion part and extended it&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<h3 class="pink">PLEASE NOTE:</h3>
<p class="pink"><strong>jQote2</strong> has been released. Please consider upgrading now!!! <a href="http://aefxx.com/jquery-plugins/jqote2/">Click here</a> for a quick summary of what&#8217;s new and what&#8217;s changed.</p>
<p>jQote (pronounced like Star Trek&#8217;s Chakotey) is basically a rewrite of <strong>John Resig&#8217;s</strong> awesome <a href="http://ejohn.org/blog/javascript-micro-templating/">JavaScript Micro-Templating</a> utility. I took his code and ported it to <a href="http://www.jquery.com/">jQuery</a>, overhauled the parsing / conversion part and extended it&#8217;s functionality to minimize everyone&#8217;s coding efforts.</p>
<p><span id="more-47"></span></p>
<p>See the <a href="api/jqote-reference/">jQote API reference</a>.</p>
<p><strong>PLEASE NOTE:</strong><br />
Version 1.1.0 now gives you the <strong>possibility of changing the tag character</strong> to something else than <% and %>. Please referr to the <a href="api/jqote-reference/">jQote API reference</a> to see how to do it.</p>
<p>So, let&#8217;s get started writing down a basic template:</p>
<pre class="code"><span class="blue">&lt;script type="text/html" id="template">
&lt;![CDATA[</span>
    &lt;p class="greetings"&gt;
        Hello <span class="pink">&lt;%= this.name %&gt;</span>, how are you doing?
        May I offer you
        <span class="pink">&lt;% this.is_starving() ? %&gt;</span>
            some tasty peasant?
        <span class="pink">&lt;% : %&gt;</span>
            a refreshing Singha?
        <span class="pink">&lt;% ; %&gt;</span>
    &lt;/p&gt;
<span class="blue">]]&gt;
&lt;/script></span></pre>
<p></p>
<p>This well-mannered code snippet &#8211; though it may not seem like much &#8211; shows some very special markup, namely <code class="pink">&lt;%= expression %></code> and <code class="pink">&lt;% statement %></code>, respectively (please notice the extra &#8216;=&#8217; sign on the first one).</p>
<p>As you may have guessed already, the code in-between these tags is mere JavaScript. To simplify things you should use the <code class="pink"><%= %></code> tag whenever you want to directly echo a variable&#8217;s value (you may as well call a function or use any other expression, as long as it returns a string).</p>
<p>Pretty self-explanatory so far, hu? But what&#8217;s with all that <code class="blue">&lt;script type="text/html"></code> and <code class="blue">&lt;![CDATA[ ... ]]&gt;</code> shmoo, you ask? Well let&#8217;s cite <strong>John Resig</strong> here:<br />
<cite>&#8220;Embedding scripts in your page that have a unknown content-type (such is the case here &#8211; the browser doesn&#8217;t know how to execute a text/html script) are simply ignored by the browser &#8211; and by search engines and screenreaders. It&#8217;s a perfect cloaking device for sneaking templates into your page. [...]&#8220;</cite></p>
<p>Good news, that is we will be able to put our template code right into our HMTL source files and it won&#8217;t show up anywhere but in the sources (btw. thanks to the usage of CDATA it&#8217;s perfectly valid markup).</p>
<p>Now for the final part of our little example we&#8217;ll need some basic scripting to induce the conversion:</p>
<pre class="code">
&lt;script type="text/javascript">
    var obj= {
        name: 'Jabberwocky',
        is_starving: function() {
            return Math.random() > 0.5;
        }
    };
    <span class="pink">$('#template').jqote(obj)</span>.appendTo($('body'));
&lt;/script></pre>
<p></p>
<p>That&#8217;s it, there&#8217;s nothing more to it than calling jQote on our template and providing it with some data object to get things started. jQote really is fun to use and cuts down on the time spent trying to inject arbitrary data into your sites. You&#8217;ll learn to love it pretty fast, I promise! Give it a try.</p>
<p>One final word: I&#8217;d like to thank <strong>John Resig</strong> for bringing this up. You rock, dude.</p>
]]></content:encoded>
			<wfw:commentRss>http://aefxx.com/jquery-plugins/jqote/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
	</channel>
</rss>

