diff --git a/package.json b/package.json index fc71d08..0f68aeb 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/tasks/dustjs.js b/tasks/dustjs.js index 0c86a29..f692971 100644 --- a/tasks/dustjs.js +++ b/tasks/dustjs.js @@ -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}); } @@ -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); }); @@ -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); @@ -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); }); @@ -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"); @@ -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; @@ -108,5 +110,5 @@ module.exports = function (grunt) { grunt.log.error(e); grunt.fail.warn("Dust.js failed to compile."); } - }); + }; };