<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>cfis : A Simple, Lightweight JavaScript Templating Engine</title>
    <link>http://cfis.savagexi.com</link>
    <atom:link rel="self" type="application/rss+xml" href="http://cfis.savagexi.com/2007/06/13/a-simple-lightweight-javascript-templating-engine?format=rss"/>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Charlie Savage's Blog</description>
    <item>
      <title>Comment on A Simple, Lightweight JavaScript Templating Engine by Sebastian Good</title>
      <description>&lt;p&gt;Clever. As a minor performance enhancement, might I suggest using a common JavaScript idiom for building large strings. Your compiler turns literals in the output into strings which are added to the &amp;#8220;out&amp;#8221; variable using +=, meaning an entire new string is allocated. These strings get bigger and bigger, leading not just to wasted memory but also (roughly) quadratic running time. Big templates will suddenly be a lot slower than small ones.&lt;/p&gt;

&lt;p&gt;Might I suggest you use the following pattern.&lt;/p&gt;

&lt;p&gt;var out = [];
out.push &amp;#8220;string1&amp;#8221;;
out.push &amp;#8220;string2&amp;#8221;;
out = out.join(&amp;#8220;&amp;#8221;); // &amp;#8220;string1string2&amp;#8221;&lt;/p&gt;

&lt;p&gt;Each generated string is simply added to a list and then in one fell swoop the (very fast) compiled function join can make them into your final output.&lt;/p&gt;</description>
      <pubDate>Wed, 13 Jun 2007 17:15:52 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:242526d7-a609-445b-a551-b9163031468f</guid>
      <link>http://cfis.savagexi.com/2007/06/13/a-simple-lightweight-javascript-templating-engine#comment-1798</link>
    </item>
    <item>
      <title>Comment on A Simple, Lightweight JavaScript Templating Engine by http://abstractfinal.blogspot.com</title>
      <description>&lt;p&gt;Very cool&amp;#8230; As you mentioned, most useful when accessing services that return json.&lt;/p&gt;</description>
      <pubDate>Wed, 13 Jun 2007 18:22:16 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:b8745d4f-c078-40ca-bcfc-1bcfe5fc81ba</guid>
      <link>http://cfis.savagexi.com/2007/06/13/a-simple-lightweight-javascript-templating-engine#comment-1799</link>
    </item>
    <item>
      <title>Comment on A Simple, Lightweight JavaScript Templating Engine by cfis</title>
      <description>&lt;p&gt;Sebastian - that is an excellent point.  I have to admit that I&amp;#8217;m a bit embarrassed that it didn&amp;#8217;t occur to me - I use the same trick a fair bit.  Anyway, I&amp;#8217;ll update the code and repost it.&lt;/p&gt;</description>
      <pubDate>Thu, 14 Jun 2007 00:10:37 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:9fcd9ad6-be9b-4e6d-a983-f7ec598bfefa</guid>
      <link>http://cfis.savagexi.com/2007/06/13/a-simple-lightweight-javascript-templating-engine#comment-1800</link>
    </item>
    <item>
      <title>Comment on A Simple, Lightweight JavaScript Templating Engine by cfis</title>
      <description>&lt;p&gt;Keyur - Thanks for the comment.  I hadn&amp;#8217;t seen your blog before, looks great. I&amp;#8217;ll have to dig through your REST posts, its a favorite topic of mine.&lt;/p&gt;</description>
      <pubDate>Thu, 14 Jun 2007 00:13:10 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:7d85772e-be09-4394-9235-177c45c7eb5e</guid>
      <link>http://cfis.savagexi.com/2007/06/13/a-simple-lightweight-javascript-templating-engine#comment-1801</link>
    </item>
    <item>
      <title>Trackback from Lucumr Cogitations: ERB for JavaScript on A Simple, Lightweight JavaScript Templating Engine</title>
      <description>Today I found this at reddit and was stunned by the way it was implemented. I now created a similar implementation, it&amp;#8217;s just a little smaller, supports escaping and doesn&amp;#8217;t use an evil delimiter hack. It supports all of the ERB goodne...</description>
      <pubDate>Thu, 14 Jun 2007 08:23:08 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:31987f92-8c68-4ab3-be05-1dfd9ee5372c</guid>
      <link>http://cfis.savagexi.com/2007/06/13/a-simple-lightweight-javascript-templating-engine#trackback-1804</link>
    </item>
    <item>
      <title>Comment on A Simple, Lightweight JavaScript Templating Engine by Ivan</title>
      <description>&lt;p&gt;&lt;a href="http://ajax-pages.sourceforge.net/" rel="nofollow"&gt;http://ajax-pages.sourceforge.net/&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 14 Jun 2007 08:59:53 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:971383f9-ec20-4e8a-aa1a-065780a8a18c</guid>
      <link>http://cfis.savagexi.com/2007/06/13/a-simple-lightweight-javascript-templating-engine#comment-1805</link>
    </item>
    <item>
      <title>Comment on A Simple, Lightweight JavaScript Templating Engine by Mark Turansky</title>
      <description>&lt;p&gt;Looks good and I like your use of the familiar &amp;lt;% and %&gt;, but concatenating that string template looks painful to me as a developer.&lt;/p&gt;

&lt;p&gt;I wrote a similar JavaScript Template engine with JSP-like syntax where you can embed the template right in the page itself w/o having to concat a large string.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blog.markturansky.com/BetterJavascriptTemplates.html" rel="nofollow"&gt;JavaScript Templates&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Wed, 05 Mar 2008 13:46:16 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:09609946-23ef-4ac1-8963-fd435e1f7579</guid>
      <link>http://cfis.savagexi.com/2007/06/13/a-simple-lightweight-javascript-templating-engine#comment-8151</link>
    </item>
  </channel>
</rss>
