Skip to content

Instantly share code, notes, and snippets.

@Sigmus
Created December 18, 2012 00:55
Show Gist options
  • Save Sigmus/4323956 to your computer and use it in GitHub Desktop.
Save Sigmus/4323956 to your computer and use it in GitHub Desktop.
app.get '/jade/*', (req, res) ->
  fs.readFile app.get('views') + "/#{req.params}.jade", 'utf-8', (err, tpl) ->
    res.json err if err
    functionBody = jade.compile(
      tpl, client:true, compileDebug:false
    ).toString().replace 'anonymous', ''
    res.set 'Content-Type', 'application/javascript'
    res.send """
      define([], function(){
        return #{functionBody}
      });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment