/* 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(t){this.__path=t.path||"./","/"!==this.__path[this.__path.length-1]&&(this.__path+="/"),this.__destination=t.destination||this.__path,"/"!==this.__destination[this.__destination.length-1]&&(this.__destination+="/"),this.__global=t.global||"window.render",this.__rendermodule=t.rendermodule||{},this.__settings=Object.prototype.hasOwnProperty.call(t,"templateSettings")?copy(t.templateSettings,copy(doT.templateSettings)):void 0,this.__includes={}}function addexports(t){for(var e="",o=0;ot;t++)o=n[t],/\.def(\.dot|\.jst)?$/.test(o)&&(doT.log&&console.log("Loaded def "+o),this.__includes[o.substring(0,o.indexOf("."))]=readdata(i+o));for(t=0,e=n.length;e>t;t++)o=n[t],/\.dot(\.def|\.jst)?$/.test(o)&&(doT.log&&console.log("Compiling "+o+" to function"),this.__rendermodule[o.substring(0,o.indexOf("."))]=this.compilePath(i+o)),/\.jst(\.dot|\.def)?$/.test(o)&&(doT.log&&console.log("Compiling "+o+" to file"),this.compileToFile(this.__destination+o.substring(0,o.indexOf("."))+".js",readdata(i+o)));return this.__rendermodule};