Skip to content

Instantly share code, notes, and snippets.

@Jman
Created March 14, 2015 05:41
Show Gist options
  • Save Jman/803733e6f6476b5533e4 to your computer and use it in GitHub Desktop.
Save Jman/803733e6f6476b5533e4 to your computer and use it in GitHub Desktop.
Compile only edited haml file (using grunt-haml2html grunt task)
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
haml: {
options: {
doubleQuoteAttributes : true
},
main: {
files : [
{ expand: true, cwd:'.', src: '**/*.haml', dest: '.', ext : '.html' }
]
},
watch: {
files : {}
}
},
watch: {
haml: {
files: '**/*.haml',
tasks: ['haml:watch'],
options: {
spawn: false
}
}
}
});
grunt.event.on('watch', function(action, filepath) {
if(filepath.indexOf('.haml') === -1) return;
grunt.log.writeln('filepath = ' + filepath);
var file = {};
var destfile = filepath.replace('.haml','.html');
file[destfile] = filepath;
grunt.config('haml.watch.files', file);
});
grunt.registerTask('default', ['haml:main']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment