Permalink
Browse files

Added coffeescript/ directory with an example testing coffeescript su…

…pport
  • Loading branch information...
1 parent b4aa078 commit 8b64e0ff2541e536d0448ca9596ce67ffed0c887 @mschwartz committed Feb 11, 2012
Showing with 35 additions and 5 deletions.
  1. +6 −0 README.md
  2. +15 −0 coffeescript/MyClass.coffee
  3. +2 −0 coffeescript/main.coffee
  4. +8 −0 coffeescript/main_action.coffee
  5. +4 −2 lib/include.js
  6. +0 −3 main_action.coffee
View
@@ -12,6 +12,12 @@ Some people say SilkJS is a synchronous version of NodeJS. It was not designed
Linux-based server applications. You might think of it as the command-line version of JavaScript, akin to command-line versions of PHP or Perl. Like in those languages,
you can implement alternatives to shell scripts, command-line applications, and even full blown Internet servers.
+## CoffeeScript
+
+SilkJS HTTPD is a full featured CoffeeScript server. For more details, see:
+
+https://github.com/mschwartz/SilkJS/wiki/CoffeeScript
+
## Features
Perhaps the greatest feature of SilkJS is that you write synchronous code; there are no callback function implementations required on your part. The theory of
@@ -0,0 +1,15 @@
+class Animal
+ constructor: (@name) ->
+
+ move: (meters) ->
+ res.write @name + " moved #{meters}m.\n"
+
+class Snake extends Animal
+ move: ->
+ res.write "Slithering...\n"
+ super 5
+
+class Horse extends Animal
+ move: ->
+ res.write "Galloping...\n"
+ super 45
View
@@ -0,0 +1,2 @@
+include 'MyClass.coffee'
+include 'main_action.coffee'
@@ -0,0 +1,8 @@
+global.main_action = () ->
+ res.write '<pre>'
+ sam = new Snake "Sammy the Python"
+ tom = new Horse "Tommy the Palomino"
+
+ sam.move()
+ tom.move()
+ res.stop()
View
@@ -40,7 +40,7 @@
fn = locateFile(fn);
var contents = fs.readFile(fn);
if (fn.indexOf(suffix, fn.length - suffixLen) !== -1) {
- contents = CoffeeScript.compile(contents);
+ contents = CoffeeScript.compile(contents, { bare: true });
}
var script = v8.compileScript(contents);
v8.runScript(script);
@@ -54,6 +54,8 @@
};
include.path = [
'./',
- '/usr/share/silkjs/lib'
+ './coffeescript',
+ '/usr/share/silkjs/lib',
+ '/usr/share/silkjs/coffeescript'
];
}());
View
@@ -1,3 +0,0 @@
-global.main_action = ->
- res.write 'hello from coffeescript'
- res.stop()

0 comments on commit 8b64e0f

Please sign in to comment.