Skip to content

Instantly share code, notes, and snippets.

@AlyxRen
Created July 21, 2010 16:49
Show Gist options
  • Save AlyxRen/484746 to your computer and use it in GitHub Desktop.
Save AlyxRen/484746 to your computer and use it in GitHub Desktop.
var fab = require('./');
for (var i in fab){
global[i] = fab[i];
}
require('http').createServer(
( fab )
( nodejs )
( contentLength )
( stringify )
( /\/date/ )
( tmpl )
( "The Date is <%= this.toDateString() %>." )
()
( /\/time/ )
( tmpl )
( "The Time is <%= this.toTimeString() %>." )
()
( new Date )
).listen( 4000 );
//error is received when you try to go to /date or /time
/*! Error Message:
/home/rixius/node/fab/apps/fab.tmpl.js:28
obj.body = fn.call( obj.body );
^
TypeError: Object [object Object] has no method 'call'
at Object.<anonymous> (/home/rixius/node/fab/apps/fab.tmpl.js:28:21)
at listener (/home/rixius/node/fab/apps/fab.map.js:10:40)
at Function.<anonymous> (/home/rixius/node/fab/apps/fab.body.js:8:15)
at /home/rixius/node/fab/apps/fab.path.js:41:21
at /home/rixius/node/fab/apps/fab.path.js:42:28
at Server.<anonymous> (/home/rixius/node/fab/apps/fab.nodejs.js:18:17)
at Server.emit (events:33:26)
at HTTPParser.onIncoming (http:825:10)
at HTTPParser.onHeadersComplete (http:87:31)
at Stream.ondata (http:757:22)
*/
@jed
Copy link

jed commented Jul 21, 2010

the problem seems to be with your use of global, since the following works:

var fab = require('fab');

require('http').createServer(

  ( fab )

  ( fab.nodejs )

  ( fab.contentLength )
  ( fab.stringify )

  ( /\/date/ )
    ( fab.tmpl )
      ( "The Date is <%= this.toDateString() %>." )
      ()

  ( /\/time/ ) 
    ( fab.tmpl )
      ( "The Time is <%= this.toTimeString() %>." )
      ()

  ( new Date )

).listen( 4000 );

@AlyxRen
Copy link
Author

AlyxRen commented Jul 21, 2010

Thanks, I don't know why i didn't try that...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment