Skip to content

Instantly share code, notes, and snippets.

@cowboy
Created March 20, 2014 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cowboy/9667689 to your computer and use it in GitHub Desktop.
Save cowboy/9667689 to your computer and use it in GitHub Desktop.
Grunt toStringify hackery
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);
});
};
$ 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