Commits

Anonymous committed 292c4f9

use 'this' as the json context within function directive

Comments (0)

Files changed (2)

 	Copyright (c) 2010 Michael Cvilic - BeeBole.com
 
 	Thanks to Rog Peppe for the functional JS jump
-	revision: 2.32
+	revision: 2.33
 */
 
 var $p, pure = $p = function(){
 	// returns the string generator function
 	function wrapquote(qfn, f){
 		return function(ctxt){
-			return qfn('' + f(ctxt));
+			return qfn('' + f.call(ctxt.context, ctxt));
 		};
 	}
 
 				old = ctxt[name],
 				temp = { items : a },
 				strs = [],
-				buildArg = function(idx){
+				buildArg = function(idx, temp){
 					ctxt.pos = temp.pos = idx;
 					ctxt.item = temp.item = a[ idx ];
 					ctxt.items = a;
-					strs.push( inner( ctxt ) );
+					strs.push( inner.call(temp, ctxt ) );
 				};
 			ctxt[name] = temp;
 			if( isArray(a) ){
 				}
 				//loop on array
 				for(var i = 0, ii = a.length || 0; i < ii; i++){  
-					buildArg(i); 
+					buildArg(i, temp); 
 				}
 			}else{
 				if(typeof sorter !== 'undefined'){
 				}
 				//loop on collections
 				for(var prop in a){
-					a.hasOwnProperty( prop ) && buildArg(prop); 
+					a.hasOwnProperty( prop ) && buildArg(prop, temp); 
 				}
 			}
 

libs/pure_packed.js

     Copyright (c) 2010 Michael Cvilic - BeeBole.com
 
 	Thanks to Rog Peppe for the functional JS jump
-    revision: 2.32
+    revision: 2.33
 */
-eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('9 $p,2v=$p=6(){9 a=2w[0],1V=I;7(u a===\'14\'){1V=2w[1]||I}8 $p.2x(a,1V)};$p.2x=6(l,q,r){9 r=2y(),1a=[];3k(u l){2z\'14\':1a=r.J(q||E,l);7(1a.x===0){F(\'1W 1X "\'+l+\'" 2A 1Y 2B\')}1E;2z\'z\':F(\'1W 1X 2C 1Z z, 3l 20 X\');1E;3m:1a=[l]}B(9 i=0,M=1a.x;i<M;i++){r[i]=1a[i]}r.x=M;9 t=\'3n\'+1F.2D(1F.2E()*2F)+\'21\',22=\'3o\'+1F.2D(1F.2E()*2F)+\'21\',23=/^(\\+)?([^\\@\\+]+)?\\@?([^\\+]+)?(\\+)?$/,2G={3p:\'3q\',3r:\'2H\'};8 r;6 F(e){3s(e);7(u 2I!==\'z\'){2I.3t(e);3u}3v(\'2v F: \'+e);}6 2y(){9 a=$p.Y,f=6(){};f.T=a;f.T.G=a.G||G;f.T.N=a.N||N;f.T.O=a.O||O;f.T.J=a.J||J;f.T.3w=1n;f.T.3x=F;8 3y f()}6 24(b){8 b.24||(6(n){9 a=E.1o(\'3z\'),h;a.1G(n.2J(Q));h=a.1p;a=15;8 h})(b)}6 1H(o){8 3A.T.3B.3C(o)==="[2K 3D]"}6 1q(b,f){8 6(a){8 b(\'\'+f(a))}}6 25(a,b){b=b||E.3E();9 c,1r;B(9 n 1b a){c=E.1o(n);b.1G(c);7(u a[n]===\'2K\'){1r=25(a[n],c)}A{1r=E.1o(a[n]);c.1G(1r)}}8 1r};6 J(n,a){7(u n===\'14\'){a=n;n=I}7(u E.2L!==\'z\'){8(n||E).2L(a)}A{F(\'3F 3G 11 2M 3H 26: 3I, 3J.5+, 3K+ 3L 3M+\\n\\3N 3O 2M 27 20 3P, 3Q 3R a 3S 3T/3U 26 a 3V X 3W\')}}6 28(c,d){8 6(a){9 b=[c[0]],n=c.x,1I,1s,1J,1t;B(9 i=1;i<n;i++){1I=d[i](a);1s=c[i];7(1I===\'\'){1J=b[b.x-1];7((1t=1J.3X(/[\\w]+=\\"?$/))>-1){b[b.x-1]=1J.29(0,1t);1s=1s.3Y(1)}}b[b.x]=1I;b[b.x]=1s}8 b.2a(\'\')}}6 2N(p){9 m=p.1u(/^(\\w+)\\s*<-\\s*(\\S+)?$/);7(m===15){F(\'2b 16 2O: "\'+p+\'"\')}7(m[1]===\'1c\'){F(\'"1c<-..." 1Z a 3Z 40 B 2c 41 42 43.\\n\\44 45 46 2d B 20 16.\')}7(!m[2]||(m[2]&&(/1d/i).11(m[2]))){m[2]=6(a){8 a.1d}}8{2d:m[1],13:m[2]}}6 1e(c){7(u(c)===\'6\'){8 c}9 m=c.1u(/^[a-47-Z$21][\\w$]*(\\.[\\w$-]*[^\\.])*$/);7(m===15){9 d=I,s=c,1K=[],1f=[],i=0,2e;7(/\\\'|\\"/.11(s.2P(0))){7(/\\\'|\\"/.11(s.2P(s.x-1))){2e=s.29(1,s.x-1);8 6(){8 2e}}}A{2Q((m=s.1u(/#\\{([^{}]+)\\}/))!==15){d=Q;1K[i++]=s.2R(0,m.2S);1f[i]=1e(m[1]);s=s.2R(m.2S+m[0].x,s.x)}}7(!d){F(\'2b 48 X 2T: \'+c)}1K[i]=s;8 28(1K,1f)}m=c.1L(\'.\');8 6(a){9 b=a.1d;7(!b){8\'\'}9 v=a[m[0]],i=0;7(v&&v.1c){b=v.1c;i+=1}9 n=m.x;B(;i<n;i++){7(!b){1E}b=b[m[i]]}8(!b&&b!==0)?\'\':b}}6 1v(c,d,e){9 f,U,X,C,P,K=[];7(u d===\'14\'){f=d;9 m=d.1u(23);7(!m){F(\'2b X 2T: \'+d)}U=m[1];X=m[2];C=m[3];P=m[4];7(X===\'.\'||(!X&&C)){K[0]=c}A{K=r.J(c,X)}7(!K||K.x===0){8 F(\'1W 1w "\'+d+\'" 2A 1Y 2B 1b 2c 1X\')}}A{U=d.U;C=d.C;P=d.P;K=[c]}7(U||P){7(U&&P){F(\'P/U 2f 49 4a 4b 2c 4c 4d\')}A 7(e){F(\'2U P/U/1g 4e 4f B 16 K\')}A 7(P&&e){F(\'2f P 26 16 (13: \'+f+\')\')}}9 g,17,V,1x,1h,1y;7(C){1x=(/^2g$/i).11(C);1h=(/^4g$/i).11(C);1y=1h?\'1i\':C;g=6(a,s){a.4h(22+C,s);7(1y 1b a&&!1x){a[1y]=\'\'}7(a.2V===1){a.2W(C);1h&&a.2W(1y)}};7(1x){17=6(a){8 a.2g.4i}}A 7(1h){17=6(a){8 a.1i}}A{17=6(a){8 a.4j(C)}}7(1x||1h){V=6(s){8 s.1g(/\\"/g,\'&2X;\')}}A{V=6(s){8 s.1g(/\\"/g,\'&2X;\').1g(/\\s/g,\'&4k;\')}}}A{7(e){g=6(a,s){9 b=a.2Y;7(b){b.2h(E.2Z(s),a.4l);b.2i(a)}}}A{17=6(a){8 a.1p};g=6(a,s,b){7(b===Q){a.1p=s}A{a.1p=\'\';a.1G(E.2Z(s))}}}V=6(s){8 s}}9 h;7(U){h=6(a,s){g(a,s+17(a),Q)}}A 7(P){h=6(a,s){g(a,17(a)+s,Q)}}A{h=6(a,s){g(a,s)}}8{C:C,L:K,30:h,13:f,V:V}}6 1z(a,n){9 b=t+n+\':\';B(9 i=0;i<a.L.x;i++){a.30(a.L[i],b)}}6 2j(e,f,g,h){8 6(c){9 a=f(c),2k=c[e],1M={31:a},2l=[],2m=6(b){c.1t=1M.1t=b;c.1c=1M.1c=a[b];c.31=a;2l.2n(g(c))};c[e]=1M;7(1H(a)){7(u h!==\'z\'){a.1N(h)}B(9 i=0,M=a.x||0;i<M;i++){2m(i)}}A{7(u h!==\'z\'){F(\'1N 1Z 4m 4n 27 4o, 1Y 4p\')}B(9 d 1b a){a.2o(d)&&2m(d)}}u 2k!==\'z\'?c[e]=2k:4q c[e];8 2l.2a(\'\')}}6 2p(a,b,c,d){9 e=I,1j,2q,H;B(H 1b c){7(c.2o(H)){7(H===\'1N\'){2q=c.1N;4r}7(e){F(\'2f 4s 4t 4u 4v 16 27 a K\')}1j=H;e=Q}}7(!1j){F(\'2U 16 2O\')}9 f=c[1j];7(u(f)===\'14\'||u(f)===\'6\'){c={};c[1j]={2C:f};8 2p(a,b,c,d)}9 g=2N(1j),1A=1e(g.13),K=1v(a,b,Q),L=K.L;B(i=0;i<L.x;i++){9 h=L[i],1B=1n(h,f);d[d.x]=1q(K.V,2j(g.2d,1A,1B,2q));K.L=[h];1z(K,d.x-1)}}6 32(n,d){9 e=n.4w(\'*\'),2r=[],1k={a:[],l:{}},y,1O,i,M,j,1l,12,1P,2s;B(i=-1,M=e.x;i<M;i++){12=i>-1?e[i]:n;7(12.2V===1&&12.1i!==\'\'){1P=12.1i.1L(\' \');B(j=0,1l=1P.x;j<1l;j++){2s=1P[j];y=33(2s,12.34);7(y!==I){1O=(/4x/i).11(y.C);7(y.13.35(\'@\')>-1||1O){12.1i=12.1i.1g(\'@\'+y.C,\'\');7(1O){y.C=I}}2r.2n({n:12,y:y})}}}}8 2r;6 33(c,a){9 b=c.1u(23),C=b[3]||2G[a],y={U:!!b[1],H:b[2],C:C,P:!!b[4],13:c},i,M,1Q,1R,W;B(i=1k.a.x-1;i>=0;i--){1Q=1k.a[i];1R=1Q.l[0];W=1R&&1R[y.H];7(u W!==\'z\'){y.H=1Q.p+\'.\'+y.H;7(1k.l[y.H]===Q){W=W[0]}1E}}7(u W===\'z\'){W=1H(d)?d[0][y.H]:d[y.H];7(u W===\'z\'){8 I}}7(1H(W)){1k.a.2n({l:W,p:y.H});1k.l[y.H]=Q;y.t=\'16\'}A{y.t=\'36\'}8 y}}6 1n(a,b,c,d){9 e=[];d=d||c&&32(a,c);7(c){9 j,1l,y,n,f,L,1A,1w,1B;2Q(d.x>0){y=d[0].y;n=d[0].n;d.4y(0,1);7(y.t===\'36\'){f=1v(n,y,I);1z(f,e.x);e[e.x]=1q(f.V,1e(y.H))}A{1A=1e(y.13);f=1v(n,y,Q);L=f.L;B(j=0,1l=L.x;j<1l;j++){1w=L[j];1B=1n(1w,I,c,d);e[e.x]=1q(f.V,2j(y.13,1A,1B));f.L=[1w];1z(f,e.x-1)}}}}9 f,1m;B(9 g 1b b){7(b.2o(g)){1m=b[g];7(u(1m)===\'6\'||u(1m)===\'14\'){f=1v(a,g,I);1z(f,e.x);e[e.x]=1q(f.V,1e(1m))}A{2p(a,g,1m,e)}}}9 h=24(a),1f=[];h=h.1g(/<([^>]+)\\s(2H\\=""|4z)\\s?([^>]*)>/4A,"<$1 $3>");h=h.1L(22).2a(\'\');9 k=h.1L(t),p;B(9 i=1;i<k.x;i++){p=k[i];1f[i]=e[4B(p,10)];k[i]=p.29(p.35(\':\')+1)}8 28(k,1f)}6 G(b,c,d){9 e=1n((d||D[0]).2J(Q),b,c);8 6(a){8 e({1d:a})}}6 N(a,b){9 c=u b===\'6\'?b:r.G(b,I,D[0]);B(9 i=0,M=D.x;i<M;i++){D[i]=2t(D[i],c(a,I))}1d=15;8 D}6 O(a,b){9 c=r.G(b,a,D[0]);B(9 i=0,M=D.x;i<M;i++){D[i]=2t(D[i],c(a,I))}1d=15;8 D}6 2t(a,b){9 c=a.34,1C,R,18,4C={1D:{}};7((/37|1S|38/).11(c)){9 d={1S:{1D:\'2u\'},37:{1D:{2u:\'1S\'}},38:{1D:{39:\'1S\'}}};R=25(d[c])}A 7((/2u|39|4D/).11(c)){R=E.1o(\'1D\')}A{R=E.1o(\'4E\')}18=a.2Y;18.2h(R,a);18.2i(a);R.2g.4F=\'4G\';R.1p=b;1C=R.4H;18.2h(1C,R);18.2i(R);a=1C;R=1C=18=15;8 a}};$p.Y={};$p.3a={1T:6(){7(u E.19===\'z\'){$p.Y.J=6(n,a){8 1T.4I(a,n)}}},3b:6(){7(u E.19===\'z\'){$p.Y.J=6(n,a){8 $(n).4J(a)}}3c.4K({4L:[\'G\',\'N\',\'O\'],G:6(a,b){8 $p(D).G(a,b)},N:6(a,b){8 $($p(D).N(a,b))[0]},O:6(a,b){8 $($p(D).O(a,b))[0]}})},3d:6(){7(u E.19===\'z\'){$p.Y.J=6(n,a){8 $(n).J(a)}}1U.4M.4N({G:6(a,b){8 $p(D[0]).G(a,b)},N:6(a,b){8 1U($p(D[0]).N(a,b))},O:6(a,b){8 1U($p(D[0]).O(a,b))}})},3e:6(){7(u E.19===\'z\'){$p.Y.J=6(n,a){8 $(n).4O(a)}}3f.4P({G:6(a,b){8 $p(D).G(a,b)},N:6(a,b){8 $p(D).N(a,b)},O:6(a,b){8 $p(D).O(a,b)}})},T:6(){7(u E.19===\'z\'){$p.Y.J=6(n,a){n=n===E?n.4Q:n;8 u n===\'14\'?$$(n):$(n).4R(a)}}3f.4S({G:6(a,b,c){8 $p(a).G(b,c)},N:6(a,b,c){8 $p(a).N(b,c)},O:6(a,b,c){8 $p(a).O(b,c)}})},3g:6(){7(u E.19===\'z\'){$p.Y.J=6(n,a){8 3h(a,n)}}},3i:6(){7(u E.19===\'z\'){$p.Y.J=6(n,a){8 3j(a,n)}}}};(6(){9 a=u 1T!==\'z\'&&\'1T\'||u 3c!==\'z\'&&\'3b\'||u 1U!==\'z\'&&\'3d\'||u 4T!==\'z\'&&\'3e\'||u 4U!==\'z\'&&\'T\'||u 3h!==\'z\'&&\'3g\'||u 3j!==\'z\'&&\'3i\';a&&$p.3a[a]()})();',62,305,'||||||function|if|return|var|||||||||||||||||||||typeof|||length|cspec|undefined|else|for|attr|this|document|error|compile|prop|false|find|target|nodes|ii|render|autoRender|append|true|pa||prototype|prepend|quotefn|val|selector|plugins|||test|ni|sel|string|null|loop|getstr|ep|querySelector|templates|in|item|context|dataselectfn|pfns|replace|isClass|className|ls|openLoops|jj|dsel|compiler|createElement|innerHTML|wrapquote|leaf|pVal|pos|match|gettarget|node|isStyle|attName|setsig|itersel|inner|ne|TABLE|break|Math|appendChild|isArray|fnVal|attLine|parts|split|temp|sort|isNodeValue|cs|loopi|loopil|TR|dojo|jQuery|ctxt|The|template|not|is|your|_|attPfx|selRx|outerHTML|domify|with|on|concatenator|substring|join|bad|the|name|retStr|cannot|style|insertBefore|removeChild|loopfn|old|strs|buildArg|push|hasOwnProperty|loopgen|sorter|an|cj|replaceWith|TBODY|pure|arguments|core|getPlugins|case|was|found|root|floor|random|1000000|autoAttr|value|console|cloneNode|object|querySelectorAll|PURE|parseloopspec|spec|charAt|while|slice|index|syntax|no|nodeType|removeAttribute|quot|parentNode|createTextNode|set|items|getAutoNodes|checkClass|tagName|indexOf|str|TD|TH|THEAD|libs|domassistant|DOMAssistant|jquery|mootools|Element|sizzle|Sizzle|sly|Sly|switch|check|default|_s|_a|IMG|src|INPUT|alert|log|debugger|throw|_compiler|_error|new|div|Object|toString|call|Array|createDocumentFragment|You|can|standalone|iPhone|FF3|Safari4|and|IE8|nTo|run|browser|you|need|JS|library|framework|CSS|engine|search|substr|reserved|word|current|running|iteration|nPlease|choose|another|zA|data|take|place|at|same|time|modifiers|allowed|class|setAttribute|cssText|getAttribute|nbsp|nextSibling|only|available|arrays|objects|delete|continue|have|more|than|one|getElementsByTagName|nodevalue|splice|selected|ig|parseInt|parent|TFOOT|SPAN|display|none|firstChild|query|cssSelect|attach|publicMethods|fn|extend|getElements|implement|body|select|addMethods|MooTools|Prototype'.split('|'),0,{}))
+var $p,pure=$p=function(){var sel=arguments[0],ctxt=false;if(typeof sel==='string'){ctxt=arguments[1]||false}return $p.core(sel,ctxt)};$p.core=function(sel,ctxt,plugins){var plugins=getPlugins(),templates=[];switch(typeof sel){case'string':templates=plugins.find(ctxt||document,sel);if(templates.length===0){error('The template "'+sel+'" was not found')}break;case'undefined':error('The template root is undefined, check your selector');break;default:templates=[sel]}for(var i=0,ii=templates.length;i<ii;i++){plugins[i]=templates[i]}plugins.length=ii;var Sig='_s'+Math.floor(Math.random()*1000000)+'_',attPfx='_a'+Math.floor(Math.random()*1000000)+'_',selRx=/^(\+)?([^\@\+]+)?\@?([^\+]+)?(\+)?$/,autoAttr={IMG:'src',INPUT:'value'};return plugins;function error(e){alert(e);if(typeof console!=='undefined'){console.log(e);debugger}throw('pure error: '+e);}function getPlugins(){var plugins=$p.plugins,f=function(){};f.prototype=plugins;f.prototype.compile=plugins.compile||compile;f.prototype.render=plugins.render||render;f.prototype.autoRender=plugins.autoRender||autoRender;f.prototype.find=plugins.find||find;f.prototype._compiler=compiler;f.prototype._error=error;return new f()}function outerHTML(node){return node.outerHTML||(function(n){var div=document.createElement('div'),h;div.appendChild(n.cloneNode(true));h=div.innerHTML;div=null;return h})(node)}function isArray(o){return Object.prototype.toString.call(o)==="[object Array]"}function wrapquote(qfn,f){return function(ctxt){return qfn(''+f.call(ctxt.context,ctxt))}}function domify(ns,pa){pa=pa||document.createDocumentFragment();var nn,leaf;for(var n in ns){nn=document.createElement(n);pa.appendChild(nn);if(typeof ns[n]==='object'){leaf=domify(ns[n],nn)}else{leaf=document.createElement(ns[n]);nn.appendChild(leaf)}}return leaf};function find(n,sel){if(typeof n==='string'){sel=n;n=false}if(typeof document.querySelectorAll!=='undefined'){return(n||document).querySelectorAll(sel)}else{error('You can test PURE standalone with: iPhone, FF3.5+, Safari4+ and IE8+\n\nTo run PURE on your browser, you need a JS library/framework with a CSS selector engine')}}function concatenator(parts,fns){return function(ctxt){var strs=[parts[0]],n=parts.length,fnVal,pVal,attLine,pos;for(var i=1;i<n;i++){fnVal=fns[i](ctxt);pVal=parts[i];if(fnVal===''){attLine=strs[strs.length-1];if((pos=attLine.search(/[\w]+=\"?$/))>-1){strs[strs.length-1]=attLine.substring(0,pos);pVal=pVal.substr(1)}}strs[strs.length]=fnVal;strs[strs.length]=pVal}return strs.join('')}}function parseloopspec(p){var m=p.match(/^(\w+)\s*<-\s*(\S+)?$/);if(m===null){error('bad loop spec: "'+p+'"')}if(m[1]==='item'){error('"item<-..." is a reserved word for the current running iteration.\n\nPlease choose another name for your loop.')}if(!m[2]||(m[2]&&(/context/i).test(m[2]))){m[2]=function(ctxt){return ctxt.context}}return{name:m[1],sel:m[2]}}function dataselectfn(sel){if(typeof(sel)==='function'){return sel}var m=sel.match(/^[a-zA-Z$_][\w$]*(\.[\w$-]*[^\.])*$/);if(m===null){var found=false,s=sel,parts=[],pfns=[],i=0,retStr;if(/\'|\"/.test(s.charAt(0))){if(/\'|\"/.test(s.charAt(s.length-1))){retStr=s.substring(1,s.length-1);return function(){return retStr}}}else{while((m=s.match(/#\{([^{}]+)\}/))!==null){found=true;parts[i++]=s.slice(0,m.index);pfns[i]=dataselectfn(m[1]);s=s.slice(m.index+m[0].length,s.length)}}if(!found){error('bad data selector syntax: '+sel)}parts[i]=s;return concatenator(parts,pfns)}m=sel.split('.');return function(ctxt){var data=ctxt.context;if(!data){return''}var v=ctxt[m[0]],i=0;if(v&&v.item){data=v.item;i+=1}var n=m.length;for(;i<n;i++){if(!data){break}data=data[m[i]]}return(!data&&data!==0)?'':data}}function gettarget(dom,sel,isloop){var osel,prepend,selector,attr,append,target=[];if(typeof sel==='string'){osel=sel;var m=sel.match(selRx);if(!m){error('bad selector syntax: '+sel)}prepend=m[1];selector=m[2];attr=m[3];append=m[4];if(selector==='.'||(!selector&&attr)){target[0]=dom}else{target=plugins.find(dom,selector)}if(!target||target.length===0){return error('The node "'+sel+'" was not found in the template')}}else{prepend=sel.prepend;attr=sel.attr;append=sel.append;target=[dom]}if(prepend||append){if(prepend&&append){error('append/prepend cannot take place at the same time')}else if(isloop){error('no append/prepend/replace modifiers allowed for loop target')}else if(append&&isloop){error('cannot append with loop (sel: '+osel+')')}}var setstr,getstr,quotefn,isStyle,isClass,attName;if(attr){isStyle=(/^style$/i).test(attr);isClass=(/^class$/i).test(attr);attName=isClass?'className':attr;setstr=function(node,s){node.setAttribute(attPfx+attr,s);if(attName in node&&!isStyle){node[attName]=''}if(node.nodeType===1){node.removeAttribute(attr);isClass&&node.removeAttribute(attName)}};if(isStyle){getstr=function(node){return node.style.cssText}}else if(isClass){getstr=function(node){return node.className}}else{getstr=function(node){return node.getAttribute(attr)}}if(isStyle||isClass){quotefn=function(s){return s.replace(/\"/g,'&quot;')}}else{quotefn=function(s){return s.replace(/\"/g,'&quot;').replace(/\s/g,'&nbsp;')}}}else{if(isloop){setstr=function(node,s){var pn=node.parentNode;if(pn){pn.insertBefore(document.createTextNode(s),node.nextSibling);pn.removeChild(node)}}}else{getstr=function(node){return node.innerHTML};setstr=function(node,s,ap){if(ap===true){node.innerHTML=s}else{node.innerHTML='';node.appendChild(document.createTextNode(s))}}}quotefn=function(s){return s}}var setfn;if(prepend){setfn=function(node,s){setstr(node,s+getstr(node),true)}}else if(append){setfn=function(node,s){setstr(node,getstr(node)+s,true)}}else{setfn=function(node,s){setstr(node,s)}}return{attr:attr,nodes:target,set:setfn,sel:osel,quotefn:quotefn}}function setsig(target,n){var sig=Sig+n+':';for(var i=0;i<target.nodes.length;i++){target.set(target.nodes[i],sig)}}function loopfn(name,dselect,inner,sorter){return function(ctxt){var a=dselect(ctxt),old=ctxt[name],temp={items:a},strs=[],buildArg=function(idx,temp){ctxt.pos=temp.pos=idx;ctxt.item=temp.item=a[idx];ctxt.items=a;strs.push(inner.call(temp,ctxt))};ctxt[name]=temp;if(isArray(a)){if(typeof sorter!=='undefined'){a.sort(sorter)}for(var i=0,ii=a.length||0;i<ii;i++){buildArg(i,temp)}}else{if(typeof sorter!=='undefined'){error('sort is only available on arrays, not objects')}for(var prop in a){a.hasOwnProperty(prop)&&buildArg(prop,temp)}}typeof old!=='undefined'?ctxt[name]=old:delete ctxt[name];return strs.join('')}}function loopgen(dom,sel,loop,fns){var already=false,ls,sorter,prop;for(prop in loop){if(loop.hasOwnProperty(prop)){if(prop==='sort'){sorter=loop.sort;continue}if(already){error('cannot have more than one loop on a target')}ls=prop;already=true}}if(!ls){error('no loop spec')}var dsel=loop[ls];if(typeof(dsel)==='string'||typeof(dsel)==='function'){loop={};loop[ls]={root:dsel};return loopgen(dom,sel,loop,fns)}var spec=parseloopspec(ls),itersel=dataselectfn(spec.sel),target=gettarget(dom,sel,true),nodes=target.nodes;for(i=0;i<nodes.length;i++){var node=nodes[i],inner=compiler(node,dsel);fns[fns.length]=wrapquote(target.quotefn,loopfn(spec.name,itersel,inner,sorter));target.nodes=[node];setsig(target,fns.length-1)}}function getAutoNodes(n,data){var ns=n.getElementsByTagName('*'),an=[],openLoops={a:[],l:{}},cspec,isNodeValue,i,ii,j,jj,ni,cs,cj;for(i=-1,ii=ns.length;i<ii;i++){ni=i>-1?ns[i]:n;if(ni.nodeType===1&&ni.className!==''){cs=ni.className.split(' ');for(j=0,jj=cs.length;j<jj;j++){cj=cs[j];cspec=checkClass(cj,ni.tagName);if(cspec!==false){isNodeValue=(/nodevalue/i).test(cspec.attr);if(cspec.sel.indexOf('@')>-1||isNodeValue){ni.className=ni.className.replace('@'+cspec.attr,'');if(isNodeValue){cspec.attr=false}}an.push({n:ni,cspec:cspec})}}}}return an;function checkClass(c,tagName){var ca=c.match(selRx),attr=ca[3]||autoAttr[tagName],cspec={prepend:!!ca[1],prop:ca[2],attr:attr,append:!!ca[4],sel:c},i,ii,loopi,loopil,val;for(i=openLoops.a.length-1;i>=0;i--){loopi=openLoops.a[i];loopil=loopi.l[0];val=loopil&&loopil[cspec.prop];if(typeof val!=='undefined'){cspec.prop=loopi.p+'.'+cspec.prop;if(openLoops.l[cspec.prop]===true){val=val[0]}break}}if(typeof val==='undefined'){val=isArray(data)?data[0][cspec.prop]:data[cspec.prop];if(typeof val==='undefined'){return false}}if(isArray(val)){openLoops.a.push({l:val,p:cspec.prop});openLoops.l[cspec.prop]=true;cspec.t='loop'}else{cspec.t='str'}return cspec}}function compiler(dom,directive,data,ans){var fns=[];ans=ans||data&&getAutoNodes(dom,data);if(data){var j,jj,cspec,n,target,nodes,itersel,node,inner;while(ans.length>0){cspec=ans[0].cspec;n=ans[0].n;ans.splice(0,1);if(cspec.t==='str'){target=gettarget(n,cspec,false);setsig(target,fns.length);fns[fns.length]=wrapquote(target.quotefn,dataselectfn(cspec.prop))}else{itersel=dataselectfn(cspec.sel);target=gettarget(n,cspec,true);nodes=target.nodes;for(j=0,jj=nodes.length;j<jj;j++){node=nodes[j];inner=compiler(node,false,data,ans);fns[fns.length]=wrapquote(target.quotefn,loopfn(cspec.sel,itersel,inner));target.nodes=[node];setsig(target,fns.length-1)}}}}var target,dsel;for(var sel in directive){if(directive.hasOwnProperty(sel)){dsel=directive[sel];if(typeof(dsel)==='function'||typeof(dsel)==='string'){target=gettarget(dom,sel,false);setsig(target,fns.length);fns[fns.length]=wrapquote(target.quotefn,dataselectfn(dsel))}else{loopgen(dom,sel,dsel,fns)}}}var h=outerHTML(dom),pfns=[];h=h.replace(/<([^>]+)\s(value\=""|selected)\s?([^>]*)>/ig,"<$1 $3>");h=h.split(attPfx).join('');var parts=h.split(Sig),p;for(var i=1;i<parts.length;i++){p=parts[i];pfns[i]=fns[parseInt(p,10)];parts[i]=p.substring(p.indexOf(':')+1)}return concatenator(parts,pfns)}function compile(directive,ctxt,template){var rfn=compiler((template||this[0]).cloneNode(true),directive,ctxt);return function(context){return rfn({context:context})}}function render(ctxt,directive){var fn=typeof directive==='function'?directive:plugins.compile(directive,false,this[0]);for(var i=0,ii=this.length;i<ii;i++){this[i]=replaceWith(this[i],fn(ctxt,false))}context=null;return this}function autoRender(ctxt,directive){var fn=plugins.compile(directive,ctxt,this[0]);for(var i=0,ii=this.length;i<ii;i++){this[i]=replaceWith(this[i],fn(ctxt,false))}context=null;return this}function replaceWith(elm,html){var tagName=elm.tagName,ne,pa,ep,parent={TABLE:{}};if((/TD|TR|TH/).test(tagName)){var parents={TR:{TABLE:'TBODY'},TD:{TABLE:{TBODY:'TR'}},TH:{TABLE:{THEAD:'TR'}}};pa=domify(parents[tagName])}else if((/TBODY|THEAD|TFOOT/).test(tagName)){pa=document.createElement('TABLE')}else{pa=document.createElement('SPAN')}ep=elm.parentNode;ep.insertBefore(pa,elm);ep.removeChild(elm);pa.style.display='none';pa.innerHTML=html;ne=pa.firstChild;ep.insertBefore(ne,pa);ep.removeChild(pa);elm=ne;pa=ne=ep=null;return elm}};$p.plugins={};$p.libs={dojo:function(){if(typeof document.querySelector==='undefined'){$p.plugins.find=function(n,sel){return dojo.query(sel,n)}}},domassistant:function(){if(typeof document.querySelector==='undefined'){$p.plugins.find=function(n,sel){return $(n).cssSelect(sel)}}DOMAssistant.attach({publicMethods:['compile','render','autoRender'],compile:function(directive,ctxt){return $p(this).compile(directive,ctxt)},render:function(ctxt,directive){return $($p(this).render(ctxt,directive))[0]},autoRender:function(ctxt,directive){return $($p(this).autoRender(ctxt,directive))[0]}})},jquery:function(){if(typeof document.querySelector==='undefined'){$p.plugins.find=function(n,sel){return $(n).find(sel)}}jQuery.fn.extend({compile:function(directive,ctxt){return $p(this[0]).compile(directive,ctxt)},render:function(ctxt,directive){return jQuery($p(this[0]).render(ctxt,directive))},autoRender:function(ctxt,directive){return jQuery($p(this[0]).autoRender(ctxt,directive))}})},mootools:function(){if(typeof document.querySelector==='undefined'){$p.plugins.find=function(n,sel){return $(n).getElements(sel)}}Element.implement({compile:function(directive,ctxt){return $p(this).compile(directive,ctxt)},render:function(ctxt,directive){return $p(this).render(ctxt,directive)},autoRender:function(ctxt,directive){return $p(this).autoRender(ctxt,directive)}})},prototype:function(){if(typeof document.querySelector==='undefined'){$p.plugins.find=function(n,sel){n=n===document?n.body:n;return typeof n==='string'?$$(n):$(n).select(sel)}}Element.addMethods({compile:function(element,directive,ctxt){return $p(element).compile(directive,ctxt)},render:function(element,ctxt,directive){return $p(element).render(ctxt,directive)},autoRender:function(element,ctxt,directive){return $p(element).autoRender(ctxt,directive)}})},sizzle:function(){if(typeof document.querySelector==='undefined'){$p.plugins.find=function(n,sel){return Sizzle(sel,n)}}},sly:function(){if(typeof document.querySelector==='undefined'){$p.plugins.find=function(n,sel){return Sly(sel,n)}}}};(function(){var libkey=typeof dojo!=='undefined'&&'dojo'||typeof DOMAssistant!=='undefined'&&'domassistant'||typeof jQuery!=='undefined'&&'jquery'||typeof MooTools!=='undefined'&&'mootools'||typeof Prototype!=='undefined'&&'prototype'||typeof Sizzle!=='undefined'&&'sizzle'||typeof Sly!=='undefined'&&'sly';libkey&&$p.libs[libkey]()})();