Skip to content

Commit

Permalink
presenter defaultTplDir fixed && isWatched is enabled only in debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
xoxulin committed Jan 21, 2014
1 parent 01a4568 commit ee93b7e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "dataflo.ws",
"description": "Zero-code JSON config-based workflow engine for Node, PhoneGap and browser.",
"version": "0.54.1",
"version": "0.55.1",
"keywords": [
"flow-based-programming",
"workflow",
Expand Down
32 changes: 17 additions & 15 deletions task/presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ var task = require ('./base'),
util = require ('util'),
stream = require('stream');

var presenters = {};
var presenters = {},
defaultTemplateDir = (project && project.config && project.config.templateDir) || 'share/presentation',
isWatched = (project && project.config && project.config.debug);

/**
* @class task.presenterTask
Expand All @@ -27,8 +29,8 @@ util.inherits (presenterTask, task);
var cache = {};

util.extend (presenterTask.prototype, {
DEFAULT_TEMPLATE_DIR: 'share/presentation',


DEFAULT_TEMPLATE_DIR: defaultTemplateDir,
/**
* @private
*/
Expand Down Expand Up @@ -143,21 +145,19 @@ util.extend (presenterTask.prototype, {
);
}

var isWatched
= ((typeof cache[self.file]) != "undefined")
&& (self.file in cache && !cache[self.file]);

cache[self.file] = presenters[self.type][compileMethod](
tplStr, self.compileParams || {}
);

if (!isWatched) {
if (isWatched) {

self.emit ('log', 'setting up watch for presentation file');
fs.watch (self.getAbsPath(), function () {
self.emit ('log', 'presentation file is changed');
delete cache[self.file];
});

}

cache[self.file] = presenters[self.type][compileMethod](
tplStr, self.compileParams || {}
);

if (self.renderMethod) {
self.renderProcess(cache[self.file][self.renderMethod].bind(cache[self.file]))
Expand Down Expand Up @@ -259,9 +259,11 @@ util.extend (presenterTask.prototype, {
break;

case 'ejs':
self.compileParams = {filename: path.resolve(
project.root.path, self.DEFAULT_TEMPLATE_DIR, self.file
)};
if (!self.compileParams) { // compileParams can be defined in task initConfig
self.compileParams = {filename: path.resolve(
project.root.path, self.DEFAULT_TEMPLATE_DIR, self.file
)};
}
case 'jade':
case 'mustache':
case 'hogan.js':
Expand Down

0 comments on commit ee93b7e

Please sign in to comment.