<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: HOW TO: Better JavaScript Templates</title>
	<atom:link href="http://blog.markturansky.com/archives/47/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.markturansky.com/archives/47</link>
	<description>software architecture &#38; engineering, code hints, sometimes philosophy, photography, life, etc.</description>
	<lastBuildDate>Thu, 19 Jan 2012 14:26:50 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Marco</title>
		<link>http://blog.markturansky.com/archives/47/comment-page-1#comment-1338</link>
		<dc:creator>Marco</dc:creator>
		<pubDate>Sun, 02 May 2010 12:58:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.markturansky.com/archives/47#comment-1338</guid>
		<description>hmm, the textarea html tag was stripped when posting the comment above. it should be between the quotes in the append call. let me know if you whant the whole source.</description>
		<content:encoded><![CDATA[<p>hmm, the textarea html tag was stripped when posting the comment above. it should be between the quotes in the append call. let me know if you whant the whole source.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marco</title>
		<link>http://blog.markturansky.com/archives/47/comment-page-1#comment-1337</link>
		<dc:creator>Marco</dc:creator>
		<pubDate>Sun, 02 May 2010 12:55:05 +0000</pubDate>
		<guid isPermaLink="false">http://blog.markturansky.com/archives/47#comment-1337</guid>
		<description>Works great! I use it in combination with Jquery and added the option to download and cache the templates:

In the evaluate function:

        // check if template already loaded before
		if(Jst.templates[src] != true)
		{
			// load the template synchronous
			$.ajaxSetup({async:false});
			$.get(Jst.templateRoot + src +&#039;.jst.html&#039;, function(data)
			{
				// create the textarea container and add the loaded template
				$(&quot;body&quot;).append(&#039;&#039;+ data +&#039;&#039;);

				// update the templates status array
				Jst.templates[src] = true;
			});

			// set the global ajax setup back to asynchronous
			$.ajaxSetup({async:true});
		}

		// parse the data with the template
        var script = Jst.parse($(&quot;#jst_&quot;+ src).text());
        eval(script);

Extra helper var&#039;s:


  // the folder where the templates are located
  templateRoot:&quot;&quot;,

  // status array keeping track if templates were loaded before
  templates:{}</description>
		<content:encoded><![CDATA[<p>Works great! I use it in combination with Jquery and added the option to download and cache the templates:</p>
<p>In the evaluate function:</p>
<p>        // check if template already loaded before<br />
		if(Jst.templates[src] != true)<br />
		{<br />
			// load the template synchronous<br />
			$.ajaxSetup({async:false});<br />
			$.get(Jst.templateRoot + src +&#8217;.jst.html&#8217;, function(data)<br />
			{<br />
				// create the textarea container and add the loaded template<br />
				$(&#8221;body&#8221;).append(&#8221;+ data +&#8221;);</p>
<p>				// update the templates status array<br />
				Jst.templates[src] = true;<br />
			});</p>
<p>			// set the global ajax setup back to asynchronous<br />
			$.ajaxSetup({async:true});<br />
		}</p>
<p>		// parse the data with the template<br />
        var script = Jst.parse($(&#8221;#jst_&#8221;+ src).text());<br />
        eval(script);</p>
<p>Extra helper var&#8217;s:</p>
<p>  // the folder where the templates are located<br />
  templateRoot:&#8221;",</p>
<p>  // status array keeping track if templates were loaded before<br />
  templates:{}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: xor</title>
		<link>http://blog.markturansky.com/archives/47/comment-page-1#comment-336</link>
		<dc:creator>xor</dc:creator>
		<pubDate>Thu, 06 Mar 2008 14:00:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.markturansky.com/archives/47#comment-336</guid>
		<description>Maybe this is of an interest: http://synodinos.wordpress.com/2008/02/22/the-way-of-client-side-templating/</description>
		<content:encoded><![CDATA[<p>Maybe this is of an interest: <a href="http://synodinos.wordpress.com/2008/02/22/the-way-of-client-side-templating/" rel="nofollow">http://synodinos.wordpress.com/2008/02/22/the-way-of-client-side-templating/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jianwu</title>
		<link>http://blog.markturansky.com/archives/47/comment-page-1#comment-333</link>
		<dc:creator>jianwu</dc:creator>
		<pubDate>Thu, 06 Mar 2008 05:26:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.markturansky.com/archives/47#comment-333</guid>
		<description>Good Idea. I have done the similar thing, but replaced &lt;% with some other tags as it will confuse the server side JSP engine. 

This is definately very important for AJAX development, as AJAX usually transfer data from server, we need a template engine to render the data for presentation to avoid mix the template logic inside the javascript code. JSP template provides a very clean seperation, at the same time, it still proivdes full power of a programming language.

I found it&#039;s much simpler to implement this kind of engine compare to using java language as javascript is a dynamic language which provides a handy &quot;eval()&quot; method.</description>
		<content:encoded><![CDATA[<p>Good Idea. I have done the similar thing, but replaced &lt;% with some other tags as it will confuse the server side JSP engine. </p>
<p>This is definately very important for AJAX development, as AJAX usually transfer data from server, we need a template engine to render the data for presentation to avoid mix the template logic inside the javascript code. JSP template provides a very clean seperation, at the same time, it still proivdes full power of a programming language.</p>
<p>I found it&#8217;s much simpler to implement this kind of engine compare to using java language as javascript is a dynamic language which provides a handy &#8220;eval()&#8221; method.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: HOW TO: Better JavaScript Templates</title>
		<link>http://blog.markturansky.com/archives/47/comment-page-1#comment-327</link>
		<dc:creator>HOW TO: Better JavaScript Templates</dc:creator>
		<pubDate>Wed, 05 Mar 2008 18:54:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.markturansky.com/archives/47#comment-327</guid>
		<description>[...] News Feeds @ LifeParticles.com wrote an interesting post today onHere&#8217;s a quick excerptHOW TO: Better JavaScript Templates Filed under Code Hints, Engineering, HOW TO, Technology JavaScript Templates (Jst) is a pure Javascript templating engine that runs in your browser using JSP-like syntax. If that doesn’t sound familiar, check out the live working example on this site and download the code. It’s Free Open Source Software. Better JavaScript Templates What&#8217;s next? Leave a comment Digg it Save This Page [...]</description>
		<content:encoded><![CDATA[<p>[...] News Feeds @ LifeParticles.com wrote an interesting post today onHere&#8217;s a quick excerptHOW TO: Better JavaScript Templates Filed under Code Hints, Engineering, HOW TO, Technology JavaScript Templates (Jst) is a pure Javascript templating engine that runs in your browser using JSP-like syntax. If that doesn’t sound familiar, check out the live working example on this site and download the code. It’s Free Open Source Software. Better JavaScript Templates What&#8217;s next? Leave a comment Digg it Save This Page [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

