Permalink
Browse files

initial release and readme update

  • Loading branch information...
addyosmani committed May 14, 2011
1 parent e1f2e3c commit 62cd79c4eda9f9e84f21dcae821f5e85af90d612
Showing with 22 additions and 0 deletions.
  1. +1 −0 README.md
  2. +21 −0 microtemplatez.js
View
@@ -0,0 +1 @@
+A very compact micro-templating solution created for learning purposes.
View
@@ -0,0 +1,21 @@
+/*!
+* Compact micro-templating implementation
+* http://addyosmani.com/
+* Licensed under the GPL
+*/
+var templatez = (function(){
+ return function(tmpl, data){
+ return tmpl.replace((RegExp("{{\\s*([a-z0-9_][\\.a-z0-9_]*)\\s*}}", "gi")), function(tag, k){
+ var path = k.split("."),
+ len = path.length,
+ temp = data,
+ i = 0;
+ for(i=0; i<len; i++){
+ temp = temp[path[i]];
+ if (i === len - 1){
+ return temp;
+ }
+ }
+ });
+ };
+}());

0 comments on commit 62cd79c

Please sign in to comment.