1
0
Fork 0
mirror of https://github.com/rails/execjs synced 2023-03-27 23:21:20 -04:00

Add a longer example to the readme

This commit is contained in:
Sam Stephenson 2011-03-10 17:21:55 -06:00
parent f81527231e
commit 608086f092

View file

@ -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};"