Permalink
Browse files

Add a longer example to the readme

  • Loading branch information...
1 parent f815272 commit 608086f092d0b72ca509cacb75b55717fa654411 @sstephenson committed Mar 10, 2011
Showing with 10 additions and 0 deletions.
  1. +10 −0 readme.md
View
@@ -21,3 +21,13 @@ A short example:
require "execjs"
ExecJS.eval "'red yellow blue'.split(' ')"
# => ["red", "yellow", "blue"]
+
+A longer example, demonstrating how to invoke the CoffeeScript compiler:
+
+ require "execjs"
+ require "open-uri"
+ source = open("http://jashkenas.github.com/coffee-script/extras/coffee-script.js").read
+
+ context = ExecJS.compile(source)
+ context.call("CoffeeScript.compile", "square = (x) -> x * x", :bare => true)
+ # => var square;\nsquare = function(x) {\n return x * x;\n};"

0 comments on commit 608086f

Please sign in to comment.