From 608086f092d0b72ca509cacb75b55717fa654411 Mon Sep 17 00:00:00 2001 From: Sam Stephenson Date: Thu, 10 Mar 2011 17:21:55 -0600 Subject: [PATCH] Add a longer example to the readme --- readme.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/readme.md b/readme.md index 1e2d636..3e6159c 100644 --- a/readme.md +++ b/readme.md @@ -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};"