grunt-bake
grunt-bake copied to clipboard
Integration of default transforms
This is an issue for discussion ideas of how default transforms can be integrated into grut-bake.
Thoughts from PR #71
Written by @david-zacharias
I believe one who uses bake frequently and takes advantage of transforms will have a basic set of transforms he uses for all bake projects. Like a max (as mapping to slice) to reduce lists or a urify to create filenames for _bake out of e.g. a news titles (had the use case today). Maybe it is an idea to ship some handy default transforms with bake? Or to create an easy way to extend bake via a npm grunt-bake-transform package containing useful transforms...
Written by @MathiasPaumgarten
There is definitely a good use for basic transforms. I like the idea of including them, but maybe we make that a separate package, or at least start breaking it into separate files :smile: I like the idea of a separate grunt-bake-transforms package. It could be a hard dependency within grunt-bake but a separate code base. Before we do that though, we might want to think about what it means if it's separate code. Might be harder to test that way.
I think a separate package is better because if someone does not need transforms he does not need to install the dependency.
Just asked myself what users want to do, maybe:
- Using all transforms (will be default case)
- Renaming / Aliasing a default transform
- Excluding / Restricting a default transform
- Still being able to add new transforms
- ...
First shot for a usage syntax where I assume that offset
and limit
are default transforms from grunt-bake-transforms
:
var BakeTransforms = require('grunt-bake-transforms');
grunt.initConfig( {
bake: {
your_target: {
options: {
transforms: BakeTransforms.extend({
offset: false, // exclude "offset"-transform
limit: 'max', // make "limit" available as "max"-transform
trancate: function(string) { // add custom transform
return ...
}
})
}
}
}
}
This way we do not even have to touch grunt-bakes current transforms handling :smiley: