Skip to content

Commit

Permalink
Merge pull request #6 from SpeCT/master
Browse files Browse the repository at this point in the history
Grunt v0.4 compatibility
  • Loading branch information
STAH committed Dec 14, 2012
2 parents 62163b9 + e2a03ef commit 0da6f92
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -31,11 +31,11 @@
"test": "grunt test"
},
"dependencies": {
"grunt": "~0.3.12",
"grunt": "~0.4.0",
"dustjs-linkedin": ">= 1.0.0"
},
"devDependencies": {
"grunt": "~0.3.12",
"grunt": "~0.4.0",
"grunt-coffee": ">= 0.0.5",
"grunt-docco": ">= 0.1.1"
},
Expand Down
16 changes: 9 additions & 7 deletions tasks/dustjs.js
Expand Up @@ -15,13 +15,13 @@ module.exports = function (grunt) {
var normalizeMultiTaskFiles = function(data, target) {
var prop, obj;
var files = [];
if (grunt.utils.kindOf(data) === 'object') {
if (grunt.util.kindOf(data) === 'object') {
if ('src' in data || 'dest' in data) {
obj = {};
if ('src' in data) { obj.src = data.src; }
if ('dest' in data) { obj.dest = data.dest; }
files.push(obj);
} else if (grunt.utils.kindOf(data.files) === 'object') {
} else if (grunt.util.kindOf(data.files) === 'object') {
for (prop in data.files) {
files.push({src: data.files[prop], dest: prop});
}
Expand All @@ -45,7 +45,7 @@ module.exports = function (grunt) {
files.forEach(function(obj) {
// Process src as a template (recursively, if necessary).
if ('src' in obj) {
obj.src = grunt.utils.recurse(obj.src, function(src) {
obj.src = grunt.util.recurse(obj.src, function(src) {
if (typeof src !== 'string') { return src; }
return grunt.template.process(src);
});
Expand All @@ -59,6 +59,8 @@ module.exports = function (grunt) {
return files;
};

var compile;

grunt.registerMultiTask("dustjs", "Grunt task to compile Dust.js templates.", function () {

this.files = this.files || normalizeMultiTaskFiles(this.data, this.target);
Expand All @@ -71,7 +73,7 @@ module.exports = function (grunt) {

srcFiles.forEach(function (srcFile) {
var sourceCode = grunt.file.read(srcFile);
var sourceCompiled = grunt.helper("dustjs", sourceCode, srcFile, options.fullname);
var sourceCompiled = compile(sourceCode, srcFile, options.fullname);

taskOutput.push(sourceCompiled);
});
Expand All @@ -83,7 +85,7 @@ module.exports = function (grunt) {
});
});

grunt.registerHelper("dustjs", function (source, filepath, fullFilename) {
compile = function (source, filepath, fullFilename) {
var path = require("path");
var dust = require("dustjs-linkedin");

Expand All @@ -98,7 +100,7 @@ module.exports = function (grunt) {
// Example: "fixtures/dust/one.dust" > "one"
name = path.basename(filepath, path.extname(filepath));
}

if (name !== undefined) {
var output = dust.compile(source, name);
return output;
Expand All @@ -108,5 +110,5 @@ module.exports = function (grunt) {
grunt.log.error(e);
grunt.fail.warn("Dust.js failed to compile.");
}
});
};
};

0 comments on commit 0da6f92

Please sign in to comment.