Skip to content

Commit

Permalink
Merge pull request #201 from halton/verbose_logging
Browse files Browse the repository at this point in the history
Add log option to disable/enable logging.
  • Loading branch information
Evgeny Poberezkin authored Nov 1, 2016
2 parents 2e29466 + ed13d2c commit 4502bad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion doT.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
doNotSkipEncoded: false
},
template: undefined, //fn, compile template
compile: undefined //fn, for express
compile: undefined, //fn, for express
log: true
}, _globals;

doT.encodeHTMLSource = function(doNotSkipEncoded) {
Expand Down
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ InstallDots.prototype.compilePath = function(path) {
};

InstallDots.prototype.compileAll = function() {
console.log("Compiling all doT templates...");
if (doT.log) console.log("Compiling all doT templates...");

var defFolder = this.__path,
sources = fs.readdirSync(defFolder),
Expand All @@ -122,19 +122,19 @@ InstallDots.prototype.compileAll = function() {
for( k = 0, l = sources.length; k < l; k++) {
name = sources[k];
if (/\.def(\.dot|\.jst)?$/.test(name)) {
console.log("Loaded def " + name);
if (doT.log) console.log("Loaded def " + name);
this.__includes[name.substring(0, name.indexOf('.'))] = readdata(defFolder + name);
}
}

for( k = 0, l = sources.length; k < l; k++) {
name = sources[k];
if (/\.dot(\.def|\.jst)?$/.test(name)) {
console.log("Compiling " + name + " to function");
if (doT.log) console.log("Compiling " + name + " to function");
this.__rendermodule[name.substring(0, name.indexOf('.'))] = this.compilePath(defFolder + name);
}
if (/\.jst(\.dot|\.def)?$/.test(name)) {
console.log("Compiling " + name + " to file");
if (doT.log) console.log("Compiling " + name + " to file");
this.compileToFile(this.__destination + name.substring(0, name.indexOf('.')) + '.js',
readdata(defFolder + name));
}
Expand Down

0 comments on commit 4502bad

Please sign in to comment.