I'm using yeoman and grunt and trying to convert haml files to html files. All my .haml files are located inside /app/source
and I want all my html files to be one level lower, inside /app
. Converting a single file works fine, this is the code I'm using in my `Gruntfile.js``
files: {
'<%= yeoman.app %>/tester.html': '<%= yeoman.app %>/source/tester.haml',
}
But I don't want to list every file separately so I tried something like this but it's not working:
files: grunt.file.expandMapping(['<%= yeoman.app %>/source/*.haml'], '<%= yeoman.app %>/source/', {
rename: function(base, path) {
return base + path.replace(/.haml$/, '.html');
}
})
This code probably wouldn't work with any subdirectories inside /source
either. So, any ideas how I should do this?
Quick answer: Building the files object dynamically
Further explanation:
expand: true; //Enable options below
cwd: '<%= yeoman.app %>/source'; //Current working directory
src: '**/*.haml'; //All files under cwd, including sub-directories
dest: '<%= yeoman.app %>'; //Destination path prefix
ext: '.html'; //Replace file's extension name
flatten: false; //KEEP folder structure
Use this piece of code to replace your original "files" property, GL.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.