Created
August 20, 2013 05:15
-
-
Save shiawuen/6277318 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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