/* Ruby-like simple string interpolation for Node.js
 * Copyright (c) 2013 Mark Vasilkov (https://github.com/mvasilkov)
 * License: MIT */
(function () {
    function rewrite(foo, bar) {
        return '"+(typeof obj["' + bar + '"]!="undefined"?obj["' + bar + '"]:"' + foo + '")+"'
    }

    function fmt(input) {
        var out = JSON.stringify(input).replace(/#\{(.*?)\}/g, rewrite)
        /* jshint evil: true */
        return Function('obj', 'return ' + out)
    }

    if (typeof module != 'undefined' && module.exports) module.exports = fmt
    else if (typeof define == 'function' && define.amd) define(function () { return fmt })
    else if (typeof window != 'undefined') window.fmt = fmt
}())

@@ -143,24 +143,44 @@
 nction () %7B%0A
+    var cache = %7B%7D%0A%0A
     function
@@ -196,24 +196,24 @@
 foo, bar) %7B%0A
-
         retu
@@ -324,24 +324,73 @@
 mt(input) %7B%0A
+        if (input in cache) return cache%5Binput%5D%0A%0A
         var 
@@ -495,16 +495,32 @@
   return
+ (cache%5Binput%5D =
  Functio
@@ -544,16 +544,17 @@
 ' + out)
+)
 %0A    %7D%0A%0A

Add template's cache support