<?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</title>
	<atom:link href="http://aefxx.com/tag/jquery/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>jQote API reference</title>
		<link>http://aefxx.com/api/jqote-reference/</link>
		<comments>http://aefxx.com/api/jqote-reference/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 15:02:03 +0000</pubDate>
		<dc:creator>aefxx</dc:creator>
				<category><![CDATA[API]]></category>
		<category><![CDATA[jQote]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://onceupon.com/?p=126</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 allows you to operate on a single template as well as a collection of templates. Any template you call jQote upon will get converted using the data object you provide.
Note: Since objects are passed [...]]]></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 allows you to operate on a single template as well as a collection of templates. Any template you call jQote upon will get converted using the data object you provide.</p>
<p><span id="more-126"></span>Note: Since objects are passed by reference you may easily alter the data object inside a template and have these changes carried over to the next iteration.</p>
<p>To make your life easier you may just as well pass an array of data objects to jQote to have your template(s) iterate over every data object provided, thus inducing n x m conversions.</p>
<h2>$.jqote_tag(tag) <span class="grey small">: method</span></h2>
<p><span class="grey">This may be used to change the default start- and ending tag character from <code>%</code> to anything you want to. Be aware that changing the tag&#8217;s char(s) this way every successive call to jQote expects the templates to be compliant to the newly set default.</span></p>
<h3>Returns</h3>
<pre class="code">void</pre>
<h3>Parameters</h3>
<pre class="code"><span class="blue">tag</span> : String</pre>
<p></p>
<h2>$().jqote(data[, tag]) <span class="grey small">: function</span></h2>
<p><span class="grey">Inside your templates you may use the <code>this</code> keyword to reference the data object&#8217;s properties. Additionally two counting variables <code>i</code> and <code>j</code> are defined (the former iterating over your templates, the latter iterating over your data objects).</span><br />
<br />
<span class="grey">You may use the optional second paramter to temporarily specify different start- and ending tag char(s). The change will overwrite the default tag char(s) just for the single call!</span></p>
<h3>Returns</h3>
<pre class="code"><span class="blue">jQuery</span> : object</pre>
<h3>Parameters</h3>
<pre class="code"><span class="blue">data</span> : object | array of object</pre>
<pre class="code"><span class="blue">tag</span> : String (optional)</pre>
<p></p>
<h3>Example</h3>
<p class="grey" style="margin: 0; padding: 0;">The infamous and obligatory &#8220;Hello World&#8221; &#8230;</p>
<p class="grey">Notice that this temporarily uses a different start- and ending tag char (the * star)!!!</p>
<pre class="code">&lt;p id="greet">&lt;/p>

&lt;script type="text/html" id="tmpl">
    &lt;![CDATA[
    I said &lt;strong><span class="blue">&lt;*= this.what *></span>&lt;/strong> !!!
    ]]&gt;
&lt;/script>
</pre>
<pre class="code">&lt;script type="text/javascript"&gt;
    <span class="grey">// let's do some jQote magic</span>
    <span class="blue">$('#tmpl').jQuote({what: 'Hello World'}, '*')</span>.appendTo($('#greet'));
&lt;/script&gt;</pre>
<div class="result">
<p id="greet">I said <strong>Hello World</strong> !!!
</div>
<p></p>
<h3>Example</h3>
<p class="grey" style="margin: 0; padding: 0;">This example will list some names of european capitals &#8230;</p>
<pre class="code">&lt;ul id="capitals"&gt;&lt;ul&gt;

<span class="grey">&lt;!-- let's define our city template --&gt;</span>
&lt;script type="text/html" id="city_tmpl"&gt;
    &lt;![CDATA[
    &lt;li class="city"&gt;
        <span class="blue">&lt;%= this.name %&gt;
        &lt;% if ( this.info ) { %&gt;</span>
        &lt;ul class="info"&gt;
            <span class="blue">&lt;% for ( key in this.info) %&gt;</span>
            &lt;li&gt;<span class="blue">&lt;%= key + ': ' +  this.info[key] %&gt;</span>&lt;/li&gt;
            <span class="blue">&lt;% ; %&gt;</span>
        &lt;/ul&gt;
        <span class="blue">&lt;% } %&gt;</span>
    &lt;/li&gt;
    ]]&gt;
&lt;/script&gt;</pre>
<pre class="code">&lt;script type="text/javascript"&gt;
    var cities = [{
        name: 'Paris',
        info: { language: 'french', sight: 'tour Eiffel' }
    }, {
        name: 'Berlin',
        info: { language: 'german', sight: 'Brandenburger Tor' }
    }];

    <span class="grey">// let's do some jQote magic</span>
    <span class="blue">$('#city_tmpl').jQuote(cities)</span>.appendTo($('#capitals'));
&lt;/script&gt;</pre>
<div class="result">
<ul>
<li>Paris
<ul>
<li>language: french</li>
<li>sight: tour Eiffel</li>
</ul>
</li>
<li>Berlin
<ul>
<li>language: german</li>
<li>sight: Brandenburger Tor</li>
</ul>
</li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://aefxx.com/api/jqote-reference/feed/</wfw:commentRss>
		<slash:comments>21</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>

