Created
August 27, 2012 22:24
-
-
Save carlosvillu/3492897 to your computer and use it in GitHub Desktop.
Precompilo en el server templates Jade y los hago AMD compatibles
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
task 'build:client:jade', 'Compile Jade template to generate AMD complient modules', (file) -> | |
dir = "#{__dirname}/application/templates" | |
readdir dir, (err, files) -> | |
throw err if err | |
files.forEach (file, index) -> | |
console.log "application/templates/#{file}" | |
module = "define(function(require){var template = {{compiled}};return template;});" | |
template = readFileSync "#{dir}/#{file}", 'utf8' | |
compiled = module.replace /{{compiled}}/, jade.compile(template, client: true).toString() | |
writeFileSync "#{__dirname}/public/js/internal/templates/#{file.replace /.jade/, '.js'}", compiled, 'utf8' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment