Skip to content

Instantly share code, notes, and snippets.

@shiawuen
Created August 20, 2013 05:15
Show Gist options
  • Save shiawuen/6277318 to your computer and use it in GitHub Desktop.
Save shiawuen/6277318 to your computer and use it in GitHub Desktop.
module.exports = function(grunt){
function slug(str){
return str.replace(/\W/g, '-')
.replace(/^\W|\W$/g, '')
.toLowerCase();
}
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jade: {
compile: {
options:{
pretty: true,
data: function(dest, src){
var projects = grunt.file.readJSON('tmp/data/projects/published.json').results;
var l = l = projects.length;
var p;
while(l--) {
// check if project name slug matched the slug from the path
// p = projects[l];
// break;
}
return {
locale: 'en',
project: p
};
}
},
files: function(){
var files = {}
, projects = grunt.file.readJSON('tmp/data/projects/published.json').results;
projects.forEach(function(p){
var name = slug(p.projectName[0].value);
files['app/' + name + '.html'] = 'views/case-study.jade';
});
return files
}
}
},
curl: {
'tmp/data/projects/published.json': 'http://example.com/path/to/json/data'
},
});
grunt.loadNpmTasks('grunt-contrib-jade');
grunt.loadNpmTasks('grunt-curl');
grunt.registerTask('compile', ['curl', 'jade']);
grunt.registerTask('default', ['compile']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment