%PDF- %PDF-
Direktori : C:/Windows/SystemApps/Microsoft.Windows.Cortana_cw5n1h2txyewy/dss_service/node_modules/dot/lib/ |
Current File : C:/Windows/SystemApps/Microsoft.Windows.Cortana_cw5n1h2txyewy/dss_service/node_modules/dot/lib/index.js |
/*! doT + auto-compilation of doT templates * * 2012, Laura Doktorova, https://github.com/olado/doT * Licensed under the MIT license * * Compiles .def, .dot, .jst files found under the specified path. * It ignores sub-directories. * Template files can have multiple extensions at the same time. * Files with .def extension can be included in other files via {{#def.name}} * Files with .dot extension are compiled into functions with the same name and * can be accessed as renderer.filename * Files with .jst extension are compiled into .js files. Produced .js file can be * loaded as a commonJS, AMD module, or just installed into a global variable * (default is set to window.render). * All inline defines defined in the .jst file are * compiled into separate functions and are available via _render.filename.definename * * Basic usage: * var dots = require("dot").process({path: "./views"}); * dots.mytemplate({foo:"hello world"}); * * The above snippet will: * 1. Compile all templates in views folder (.dot, .def, .jst) * 2. Place .js files compiled from .jst templates into the same folder. * These files can be used with require, i.e. require("./views/mytemplate"). * 3. Return an object with functions compiled from .dot templates as its properties. * 4. Render mytemplate template. */ function InstallDots(n){this.__path=n.path||"./";this.__path[this.__path.length-1]!=="/"&&(this.__path+="/");this.__destination=n.destination||this.__path;this.__destination[this.__destination.length-1]!=="/"&&(this.__destination+="/");this.__global=n.global||"window.render";this.__rendermodule=n.rendermodule||{};this.__settings=n.templateSettings?copy(n.templateSettings,copy(doT.templateSettings)):undefined;this.__includes={}}function addexports(n){for(var i="",t=0;t<n.length;t++)i+="itself."+n[t]+"="+n[t]+";";return i}function copy(n,t){t=t||{};for(var i in n)t[i]=n[i];return t}function readdata(n){var t=fs.readFileSync(n);if(t)return t.toString();console.log("problems with "+n)}var fs=require("fs"),doT=module.exports=require("./doT");doT.process=function(n){return new InstallDots(n).compileAll()};InstallDots.prototype.compileToFile=function(n,t,i){var r;i=i||{};var e=n.substring(n.lastIndexOf("/")+1,n.lastIndexOf(".")),u=copy(this.__includes,copy(i)),o=this.__settings||doT.templateSettings,h=copy(o),l=doT.template(t,o,u),c=[],s="",f;for(r in u)u[r]!==i[r]&&u[r]!==this.__includes[r]&&(f=undefined,typeof u[r]=="string"?f=doT.template(u[r],o,u):typeof u[r]=="function"?f=u[r]:u[r].arg&&(h.varname=u[r].arg,f=doT.template(u[r].text,h,u)),f&&(s+=f.toString().replace("anonymous",r),c.push(r)));s+=l.toString().replace("anonymous",e);fs.writeFileSync(n,"(function(){"+s+"var itself="+e+";"+addexports(c)+"if(typeof module!=='undefined' && module.exports) module.exports=itself;else if(typeof define==='function')define(function(){return itself;});else {"+this.__global+"="+this.__global+"||{};"+this.__global+"['"+e+"']=itself;}}());")};InstallDots.prototype.compilePath=function(n){var t=readdata(n);if(t)return doT.template(t,this.__settings||doT.templateSettings,copy(this.__includes))};InstallDots.prototype.compileAll=function(){console.log("Compiling all doT templates...");for(var i=this.__path,r=fs.readdirSync(i),n,t=0,u=r.length;t<u;t++)n=r[t],/\.def(\.dot|\.jst)?$/.test(n)&&(console.log("Loaded def "+n),this.__includes[n.substring(0,n.indexOf("."))]=readdata(i+n));for(t=0,u=r.length;t<u;t++)n=r[t],/\.dot(\.def|\.jst)?$/.test(n)&&(console.log("Compiling "+n+" to function"),this.__rendermodule[n.substring(0,n.indexOf("."))]=this.compilePath(i+n)),/\.jst(\.dot|\.def)?$/.test(n)&&(console.log("Compiling "+n+" to file"),this.compileToFile(this.__destination+n.substring(0,n.indexOf("."))+".js",readdata(i+n)));return this.__rendermodule}