Skip to content

Instantly share code, notes, and snippets.

@carlosvillu
Created August 27, 2012 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlosvillu/3492897 to your computer and use it in GitHub Desktop.
Save carlosvillu/3492897 to your computer and use it in GitHub Desktop.
Precompilo en el server templates Jade y los hago AMD compatibles
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