substitute-min.js revision 637be785ab98741335d5cd6634fddc5f6ecdb41b
YUI.add("substitute",function(G){var B=G.Lang,D="dump",F=" ",C="{",E="}",A=function(U,I,P,K,H){var N,M,L,S,R,T,Q=[],J,O;K=K||C;H=H||E;for(;;){N=U.lastIndexOf(K);if(N<0){break;}M=U.indexOf(H,N);if(N+1>=M){break;}J=U.substring(N+1,M);S=J;T=null;L=S.indexOf(F);if(L>-1){T=S.substring(L+1);S=S.substring(0,L);}R=I[S];if(P){R=P(S,R,T);}if(B.isObject(R)){if(!G.dump){R=R.toString();}else{if(B.isArray(R)){R=G.dump(R,parseInt(T,10));}else{T=T||"";O=T.indexOf(D);if(O>-1){T=T.substring(4);}if(R.toString===Object.prototype.toString||O>-1){R=G.dump(R,parseInt(T,10));}else{R=R.toString();}}}}else{if(!B.isString(R)&&!B.isNumber(R)){R="~-"+Q.length+"-~";Q[Q.length]=J;}}U=U.substring(0,N)+R+U.substring(M+1);}for(N=Q.length-1;N>=0;N=N-1){U=U.replace(new RegExp("~-"+N+"-~"),K+Q[N]+H,"g");}return U;};(function(){var M=/\{\s*([^|{}]+?)\s*(?:\|([^\{}]*))?\s*\}/g,O=100,J=function(Q,P){return function(S,U,R){var T=Q[U];return T!==undefined?T:(P.preserve?S:"");};},L=function(Q,T,S){var R=Q,P=0;do{Q=R;console.log("pass: "+P);console.log("s: "+G.dump(Q));console.log("o: "+G.dump(T));R=H(Q,T,S);}while(R!==Q&&++P<O);return R;},I=/\{/g,K=/\}/g,N={},H=function(Q,V,S){S=S||N;if(false!==S.recurse){S.recurse=false;return L.apply(this,arguments);}var P=S.ldelim,T=S.rdelim,U=S.pattern||M,R=S.replacer||J;if(P||T&&!S.pattern){M=M.replace(I,P).replace(K,T);}return Q&&Q.replace?Q.replace(U,R(V,S)):Q;};G.substitute=H;B.substitute=H;})();},"@VERSION@",{optional:["dump"]});