Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added whiskers.js

  • Loading branch information...
commit be8124c3262e01951b6db8f38969f5addbc5c16b 1 parent 01241d8
@tj authored
Showing with 2 additions and 0 deletions.
  1. +2 −0  public/javascripts/whiskers.js
View
2  public/javascripts/whiskers.js
@@ -0,0 +1,2 @@
+// whiskers.js templating library v0.1.2
+(function(a){function b(a,b){var c=b.split(".");for(var d=0,e=c.length;d<e;d++){a=a[c[d]];if(!a)break}return a===undefined&&(a=""),a}a.cache={},a.render=function(b,c,d){return c=c||{},d=d||{},a.cache[b]||(a.cache[b]=a.compile(b)),a.cache[b](c,d)},a.compile=function(c){c=(c||"")+"",c=c.replace(/\\/g,"\\\\").replace(/\'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,""),c=c.replace(/(\\*){![\s\S]*?!}/g,function(a,b){return b?a.replace("\\\\",""):""});var d=[],e;c=c.replace(/(\\*){(?:([\w_.]+)|>([\w_.]+)|for +([\w_]+) +in +([\w_.]+)|if +(not +|)([\w_.]+)|\/(for|if))}/g,function(a,b,c,f,g,h,i,j,k,l,m){if(b)return a.replace("\\\\","");if(c){if(c=="else"){e=d[d.length-1];if(e&&!e.elsed){e.elsed=!0;if(e.statement=="if")return"'}else{b+='";if(e.statement=="for")return"'}if(!g(c,'"+e.key+"')){b+='"}return console.warn("extra {else} ignored"),""}return"'+g(c,'"+c+"')+'"}return f?"'+r(g(p,'"+f+"'),c,p)+'":h?(d.push({statement:"for",key:h}),"';var "+g+"A=g(c,'"+h+"');for(var "+g+"I=0;"+g+"I<"+g+"A.length;"+g+"I++){c['"+g+"']="+g+"A["+g+"I];b+='"):j?(d.push({statement:"if"}),"';if("+(i?"!":"")+"g(c,'"+j+"')){b+='"):k?(e=d[d.length-1],e&&e.statement==k?(d.pop(),"'}b+='"):(console.warn("extra {/"+k+"} ignored"),"")):a});for(var f=d.length-1;f>-1;f--)e=d[f],console.warn("extra {"+e.statement+"} closed at end of template"),c+="'}b+='";var g=new Function("g","r","return function(c,p){var b='"+c+"';return b}");return g(b,a.render)}})(typeof module=="object"?module.exports:window.whiskers={})
Please sign in to comment.
Something went wrong with that request. Please try again.