EDIT: Since this answer was initially posted, a permalinks plugin was published that makes this super easy: https://github.com/assemble/assemble-contrib-permalinks
I think a better approach would be to create a feature request at http://github.com/assemble/assemble/issues, however, if you prefer to find a way to use custom logic in lodash templates inside the gruntfile, then my suggestion would be to create mixins that can then be used in your templates.
To add mixins, just do something like this outside the initConfig
object (there are other ways, but this is easiest):
module.exports = function (grunt) {
grunt.util._.mixin({
year: function(foo) {
return date.getFullYear(foo);
},
month: function(foo) {
return date.getMonth(foo);
},
day: function(foo) {
return date.getDay(foo);
}
});
grunt.initConfig({
foo: {
src: 'path/to/my/files/**`
// Now we can use the mixins like this:
dest: <%= _.year() %>/<%= _.month() %>/<%= _.day() %>'
});
grunt.registerTask(...);
};
The challenge with this approach is getting the context from the YAML front matter of the src
files and then returning the dates to be used in the dest
paths. Alternatively, this should't be difficult to implement as a native feature in assemble, and I think others would benefit from it as well.