Skip to content
Browse files

uglify with mangling

  • Loading branch information...
1 parent a448316 commit bd5bffeebabc1d7e97715c29232e90676f3ddd4c Max Melentiev committed Apr 8, 2013
Showing with 2 additions and 2 deletions.
  1. +1 −1 Makefile
  2. +1 −1 doT.min.js
View
2 Makefile
@@ -15,7 +15,7 @@ compile: $(TARGETS)
$(COFFEE) -co ./ "$<"
%.min.js: %.js
- $(UGLIFY) -o "$@" "$<"
+ $(UGLIFY) -m -o "$@" "$<"
clean:
rm -f $(TARGETS) $(UGLIFIED)
View
2 doT.min.js
@@ -1 +1 @@
-(function(){"use strict";var cache,doT,mangles,resolveDefs,sid,skip,startend,tags,unescape;startend={append:{start:"' + (",end:") + '",endEncode:").encodeHTML() + '"},split:{start:"'; out += (",end:"); out += '",endEncode:").encodeHTML(); out += '"}};doT={version:"0.2.0",templateSettings:{use:/\{\{#([\s\S]+?)\}\}/g,define:/\{\{##\s*([\w\.$]+)\s*(\:|=)([\s\S]+?)#\}\}/g,varname:"it",strip:true,"with":true,dynamicList:"it._dynamic",startend:startend.append},startend:startend,mangles:{},tags:{}};cache={};sid=0;skip=/$^/;if(typeof module!=="undefined"&&module!==null?module.exports:void 0){module.exports=doT}else if(typeof define!=="undefined"&&define!==null?define.amd:void 0){define(function(){return doT})}else{this.doT=doT}if(!String.prototype.encodeHTML){(function(){var match,rules;rules={"&":"&#38;","<":"&#60;",">":"&#62;",'"':"&#34;","'":"&#39;","/":"&#47;"};match=/&(?!#?\w+;)|<|>|"|'|\//g;return String.prototype.encodeHTML=function(){return this.replace(match,function(m){return rules[m]||m})}})()}doT.unescape=unescape=function(code){return code.replace(/\\('|\\)/g,"$1").replace(/[\r\t\n]/g," ")};tags=doT.tags;tags.interpolate={regex:/\{\{\s*=([\s\S]*?)\}\}/g,func:function(m,code){var cse;cse=doT.templateSettings.startend;return cse.start+unescape(code)+cse.end}};tags.encode={regex:/\{\{\s*!([\s\S]*?)\}\}/g,func:function(m,code){var cse;cse=doT.templateSettings.startend;return cse.start+unescape(code)+cse.endEncode}};tags.conditional={regex:/\{\{\s*\?(\?)?\s*([\s\S]*?)\}\}/g,func:function(m,elsecase,code){if(elsecase){if(code){return"' ; } else if ( "+unescape(code)+" ) { out += '"}else{return"'; } else { out += '"}}else{if(code){return"'; if ( "+unescape(code)+" ) { out += '"}else{return"'; } out += '"}}}};tags.iterate={regex:/\{\{\s*~\s*(?:(\S+?)\s*\:\s*([\w$]+)\s*(?:=>\s*([\w$]+))?\s*)?\}\}/g,func:function(m,iterate,iname,vname){var _ref;if(!iterate){return"'; } } out += '"}if(!vname){_ref=[iname,"i"+ ++sid],vname=_ref[0],iname=_ref[1]}iterate=unescape(iterate);return"'; var arr"+sid+" = "+iterate+"; if( arr"+sid+" ) { var "+vname+", "+iname+" = -1, l"+sid+" = arr"+sid+".length-1; while( "+iname+" < l"+sid+" ){ "+vname+" = arr"+sid+"["+iname+" += 1]; out += '"}};tags.iterateFor={regex:/\{\{\s*:\s*(?:(\S+?)\s*\:\s*([\w$]+)\s*(?:=>\s*([\w$]+))?\s*)?\}\}/g,func:function(m,iterate,iname,vname){var inpname,_ref;if(!iterate){return"'; } } out += '"}inpname="i"+ ++sid;if(!vname){_ref=[iname,"i"+ ++sid],vname=_ref[0],iname=_ref[1]}return"'; var "+inpname+" = "+iterate+"; if ( "+inpname+" ) { var "+vname+", "+iname+"; for ("+iname+" in "+inpname+" ) { "+vname+" = "+inpname+"[ "+iname+" ]; out += '"}};tags.content_for={regex:/\{\{\s*>([\s\S]*?)\}\}/g,func:function(m,id){this.multiple_contents=true;if(id){return"'; contents[current_out] = out; out_stack.push(current_out); current_out='"+unescape(id).trim()+"'; out = contents[current_out] = '"}else{return"'; contents[current_out] = out; out = contents[current_out = out_stack.pop()] += '"}}};tags.xx_includeDynamic={regex:/\{\{\s*@@\s*(\S+?)\(([\s\S]*?)\)\s*\}\}/g,func:function(m,tmpl,args){var vname;sid+=1;vname="tmpl"+sid;return"'; var "+vname+" = "+doT.templateSettings.dynamicList+"[ '"+unescape(tmpl)+"' ]; if ('string' === typeof "+vname+") "+vname+" = {name: "+vname+"}; out += doT.render({name: "+vname+".name, args: "+vname+".args || arguments}) + '"}};tags.xy_render={regex:/\{\{\s*@\s*(\S+?)\(([\s\S]*?)\)\s*\}\}/g,func:function(m,tmpl,args){return"' + doT.render( '"+tmpl+"' "+(args?","+unescape(args):"")+" ) + '"}};tags.zz_evaluate={regex:/\{\{([\s\S]*?)\}\}/g,func:function(m,code){return"'; "+unescape(code)+"; out += '"}};mangles=doT.mangles;mangles["05_define"]=resolveDefs=function(block,compileParams){var c,def;if(!(this.use||this.define)){return str}c=this;def=compileParams.def||{};return block.toString().replace(c.define||skip,function(m,code,assign,value){if(code.indexOf("def.")===0){code=code.substring(4)}if(!(code in def)){if(assign===":"){if(c.defineParams){value.replace(c.defineParams,function(m,param,v){return def[code]={arg:param,text:v}})}if(!(code in def)){def[code]=value}}else{new Function("def","def['"+code+"'] = "+value)(def)}}return""}).replace(c.use||skip,function(m,code){var v;if(c.useParams){code=code.replace(c.useParams,function(m,s,d,param){var rw;if(def[d]&&def[d].arg&&param){rw=(d+":"+param).replace(/'|\\/g,"_");def.__exp=def.__exp||{};def.__exp[rw]=def[d].text.replace(new RegExp("(^|[^\\w$])"+def[d].arg+"([^\\w$])","g"),"$1"+param+"$2");return s+("def.__exp['"+rw+"']")}})}v=new Function("def","return "+code)(def);if(v){return resolveDefs.call(c,v,compileParams)}else{return v}})};mangles["10_strip"]=function(str,compileParams){if(!this.strip){return str}return str.replace(/(^|\r|\n)\t* +| +\t*(\r|\n|$)/g," ").replace(/\r|\n|\t|\/\*[\s\S]*?\*\//g,"")};mangles["20_escape_quotes"]=function(str,compileParams){return str.replace(/'|\\/g,"\\$&")};mangles["50_tags"]=function(str,compileParams){var t_id,t_name,taglist;taglist=Object.keys(doT.tags).sort();for(t_id in taglist){t_name=taglist[t_id];str=str.replace(doT.tags[t_name].regex,function(){return doT.tags[t_name].func.apply(compileParams,arguments)})}return str};mangles["70_escape_spaces"]=function(str,compileParams){return str.replace(/\n/g,"\\n").replace(/\t/g,"\\t").replace(/\r/g,"\\r")};mangles["80_cleanup"]=function(str,compileParams){return str.replace(/(\s|;|}|^|{)out\+='';/g,"$1").replace(/\s*\+\s*''/g,"").replace(/(\s|;|}|^|{)out\+=''\+/g,"$1out+=")};mangles["80_function_basics"]=function(str,compileParams){if(compileParams.multiple_contents){return" var out_stack = [], contents = {}, current_out = '_content'; var out = '"+str+"'; contents[current_out] = out; return contents; "}else{return" var out = '"+str+"'; return out; "}};mangles["80_with"]=function(str,compileParams){if(!this["with"]){return str}return"with("+(true===this["with"]?this.varname:this["with"])+") {"+str+"}"};mangles["95_functionize"]=function(str,compileParams){try{return new Function(this.varname,str)}catch(e){throw new Error(""+e+' in "'+str+'"')}};doT.compile=function(tmpl,def){var compile_params,m_id,m_name,mangles_list;compile_params={def:def};mangles_list=Object.keys(doT.mangles).sort();for(m_id in mangles_list){m_name=mangles_list[m_id];tmpl=doT.mangles[m_name].call(doT.templateSettings,tmpl,compile_params)}return tmpl};doT.template=doT.compile;doT.getCached=function(tmpl){if(!tmpl){return cache}if(!cache[tmpl]){throw new Error("Template not found: "+tmpl)}return cache[tmpl]};doT.setCached=function(fns){return cache=fns};doT.exportCached=function(){var f,id,str;str="";for(id in cache){f=cache[id];str+=',"'+id+'": '+f.toString()}return"{"+str.slice(1)+"}"};doT.addCached=function(id,fn){var f,i;if("object"===typeof id){for(i in id){f=id[i];doT.addCached(i,f)}return}return cache[id]=fn};doT.render=function(tmpl){var src;if("object"!==typeof tmpl){tmpl={name:tmpl}}if(!cache[tmpl.name]){src=doT.autoload(tmpl.name);if(false===src){throw new Error("Template not found: "+tmpl.name)}doT.addCached(tmpl.name,doT.compile(src))}return cache[tmpl.name].apply(this,tmpl.args||Array.prototype.slice.call(arguments,1))};doT.autoloadDOM=function(opts){return function(name){var src;src=document.getElementById(name);if((src!=null?src.type:void 0)!=="text/x-dot-tmpl"){return false}return src.innerHTML}};doT.autoloadFS=function(opts){return function(name){try{return opts.fs.readFileSync(""+opts.root+"/"+name.replace(".","/")+".tmpl")}catch(e){return false}}};doT.autoloadFail=function(){return false};doT.autoload=doT.autoloadDOM()}).call(this);
+(function(){"use strict";var e,t,n,r,u,i,o,a,s;o={append:{start:"' + (",end:") + '",endEncode:").encodeHTML() + '"},split:{start:"'; out += (",end:"); out += '",endEncode:").encodeHTML(); out += '"}};t={version:"0.2.0",templateSettings:{use:/\{\{#([\s\S]+?)\}\}/g,define:/\{\{##\s*([\w\.$]+)\s*(\:|=)([\s\S]+?)#\}\}/g,varname:"it",strip:true,"with":true,dynamicList:"it._dynamic",startend:o.append},startend:o,mangles:{},tags:{}};e={};u=0;i=/$^/;if(typeof module!=="undefined"&&module!==null?module.exports:void 0){module.exports=t}else if(typeof define!=="undefined"&&define!==null?define.amd:void 0){define(function(){return t})}else{this.doT=t}if(!String.prototype.encodeHTML){(function(){var e,t;t={"&":"&#38;","<":"&#60;",">":"&#62;",'"':"&#34;","'":"&#39;","/":"&#47;"};e=/&(?!#?\w+;)|<|>|"|'|\//g;return String.prototype.encodeHTML=function(){return this.replace(e,function(e){return t[e]||e})}})()}t.unescape=s=function(e){return e.replace(/\\('|\\)/g,"$1").replace(/[\r\t\n]/g," ")};a=t.tags;a.interpolate={regex:/\{\{\s*=([\s\S]*?)\}\}/g,func:function(e,n){var r;r=t.templateSettings.startend;return r.start+s(n)+r.end}};a.encode={regex:/\{\{\s*!([\s\S]*?)\}\}/g,func:function(e,n){var r;r=t.templateSettings.startend;return r.start+s(n)+r.endEncode}};a.conditional={regex:/\{\{\s*\?(\?)?\s*([\s\S]*?)\}\}/g,func:function(e,t,n){if(t){if(n){return"' ; } else if ( "+s(n)+" ) { out += '"}else{return"'; } else { out += '"}}else{if(n){return"'; if ( "+s(n)+" ) { out += '"}else{return"'; } out += '"}}}};a.iterate={regex:/\{\{\s*~\s*(?:(\S+?)\s*\:\s*([\w$]+)\s*(?:=>\s*([\w$]+))?\s*)?\}\}/g,func:function(e,t,n,r){var i;if(!t){return"'; } } out += '"}if(!r){i=[n,"i"+ ++u],r=i[0],n=i[1]}t=s(t);return"'; var arr"+u+" = "+t+"; if( arr"+u+" ) { var "+r+", "+n+" = -1, l"+u+" = arr"+u+".length-1; while( "+n+" < l"+u+" ){ "+r+" = arr"+u+"["+n+" += 1]; out += '"}};a.iterateFor={regex:/\{\{\s*:\s*(?:(\S+?)\s*\:\s*([\w$]+)\s*(?:=>\s*([\w$]+))?\s*)?\}\}/g,func:function(e,t,n,r){var i,o;if(!t){return"'; } } out += '"}i="i"+ ++u;if(!r){o=[n,"i"+ ++u],r=o[0],n=o[1]}return"'; var "+i+" = "+t+"; if ( "+i+" ) { var "+r+", "+n+"; for ("+n+" in "+i+" ) { "+r+" = "+i+"[ "+n+" ]; out += '"}};a.content_for={regex:/\{\{\s*>([\s\S]*?)\}\}/g,func:function(e,t){this.multiple_contents=true;if(t){return"'; contents[current_out] = out; out_stack.push(current_out); current_out='"+s(t).trim()+"'; out = contents[current_out] = '"}else{return"'; contents[current_out] = out; out = contents[current_out = out_stack.pop()] += '"}}};a.xx_includeDynamic={regex:/\{\{\s*@@\s*(\S+?)\(([\s\S]*?)\)\s*\}\}/g,func:function(e,n,r){var i;u+=1;i="tmpl"+u;return"'; var "+i+" = "+t.templateSettings.dynamicList+"[ '"+s(n)+"' ]; if ('string' === typeof "+i+") "+i+" = {name: "+i+"}; out += doT.render({name: "+i+".name, args: "+i+".args || arguments}) + '"}};a.xy_render={regex:/\{\{\s*@\s*(\S+?)\(([\s\S]*?)\)\s*\}\}/g,func:function(e,t,n){return"' + doT.render( '"+t+"' "+(n?","+s(n):"")+" ) + '"}};a.zz_evaluate={regex:/\{\{([\s\S]*?)\}\}/g,func:function(e,t){return"'; "+s(t)+"; out += '"}};n=t.mangles;n["05_define"]=r=function(e,t){var n,u;if(!(this.use||this.define)){return str}n=this;u=t.def||{};return e.toString().replace(n.define||i,function(e,t,r,i){if(t.indexOf("def.")===0){t=t.substring(4)}if(!(t in u)){if(r===":"){if(n.defineParams){i.replace(n.defineParams,function(e,n,r){return u[t]={arg:n,text:r}})}if(!(t in u)){u[t]=i}}else{new Function("def","def['"+t+"'] = "+i)(u)}}return""}).replace(n.use||i,function(e,i){var o;if(n.useParams){i=i.replace(n.useParams,function(e,t,n,r){var i;if(u[n]&&u[n].arg&&r){i=(n+":"+r).replace(/'|\\/g,"_");u.__exp=u.__exp||{};u.__exp[i]=u[n].text.replace(new RegExp("(^|[^\\w$])"+u[n].arg+"([^\\w$])","g"),"$1"+r+"$2");return t+("def.__exp['"+i+"']")}})}o=new Function("def","return "+i)(u);if(o){return r.call(n,o,t)}else{return o}})};n["10_strip"]=function(e,t){if(!this.strip){return e}return e.replace(/(^|\r|\n)\t* +| +\t*(\r|\n|$)/g," ").replace(/\r|\n|\t|\/\*[\s\S]*?\*\//g,"")};n["20_escape_quotes"]=function(e,t){return e.replace(/'|\\/g,"\\$&")};n["50_tags"]=function(e,n){var r,u,i;i=Object.keys(t.tags).sort();for(r in i){u=i[r];e=e.replace(t.tags[u].regex,function(){return t.tags[u].func.apply(n,arguments)})}return e};n["70_escape_spaces"]=function(e,t){return e.replace(/\n/g,"\\n").replace(/\t/g,"\\t").replace(/\r/g,"\\r")};n["80_cleanup"]=function(e,t){return e.replace(/(\s|;|}|^|{)out\+='';/g,"$1").replace(/\s*\+\s*''/g,"").replace(/(\s|;|}|^|{)out\+=''\+/g,"$1out+=")};n["80_function_basics"]=function(e,t){if(t.multiple_contents){return" var out_stack = [], contents = {}, current_out = '_content'; var out = '"+e+"'; contents[current_out] = out; return contents; "}else{return" var out = '"+e+"'; return out; "}};n["80_with"]=function(e,t){if(!this["with"]){return e}return"with("+(true===this["with"]?this.varname:this["with"])+") {"+e+"}"};n["95_functionize"]=function(e,t){try{return new Function(this.varname,e)}catch(n){throw new Error(""+n+' in "'+e+'"')}};t.compile=function(e,n){var r,u,i,o;r={def:n};o=Object.keys(t.mangles).sort();for(u in o){i=o[u];e=t.mangles[i].call(t.templateSettings,e,r)}return e};t.template=t.compile;t.getCached=function(t){if(!t){return e}if(!e[t]){throw new Error("Template not found: "+t)}return e[t]};t.setCached=function(t){return e=t};t.exportCached=function(){var t,n,r;r="";for(n in e){t=e[n];r+=',"'+n+'": '+t.toString()}return"{"+r.slice(1)+"}"};t.addCached=function(n,r){var u,i;if("object"===typeof n){for(i in n){u=n[i];t.addCached(i,u)}return}return e[n]=r};t.render=function(n){var r;if("object"!==typeof n){n={name:n}}if(!e[n.name]){r=t.autoload(n.name);if(false===r){throw new Error("Template not found: "+n.name)}t.addCached(n.name,t.compile(r))}return e[n.name].apply(this,n.args||Array.prototype.slice.call(arguments,1))};t.autoloadDOM=function(e){return function(e){var t;t=document.getElementById(e);if((t!=null?t.type:void 0)!=="text/x-dot-tmpl"){return false}return t.innerHTML}};t.autoloadFS=function(e){return function(t){try{return e.fs.readFileSync(""+e.root+"/"+t.replace(".","/")+".tmpl")}catch(n){return false}}};t.autoloadFail=function(){return false};t.autoload=t.autoloadDOM()}).call(this);

0 comments on commit bd5bffe

Please sign in to comment.
Something went wrong with that request. Please try again.