Created
March 20, 2014 16:20
-
-
Save cowboy/9667689 to your computer and use it in GitHub Desktop.
Grunt toStringify hackery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(grunt) { | |
function toStringify(obj, toString) { | |
obj.toString = toString; | |
return obj; | |
} | |
grunt.initConfig({ | |
stuff: { | |
foo: ['l', 'o', 'l'], | |
bar: toStringify(['w', 'u', 't'], function() { | |
return this.join('-'); | |
}), | |
baz: toStringify(['o', 'm', 'g'], function() { | |
return this.join('').toUpperCase(); | |
}), | |
}, | |
build: { | |
options: { | |
arr: ['<%= stuff.foo %>', '<%= stuff.bar %>', '<%= stuff.baz %>'], | |
str: '<%= stuff.foo %> and <%= stuff.bar %> and <%= stuff.baz %>', | |
}, | |
}, | |
}); | |
grunt.registerTask('build', function() { | |
var options = this.options(); | |
console.log(options.arr); | |
console.log(options.str); | |
}); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ grunt build | |
Running "build" task | |
[ [ 'l', 'o', 'l' ], [ 'w', 'u', 't' ], [ 'o', 'm', 'g' ] ] | |
l,o,l and w-u-t and OMG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment