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:
parent
f81527231e
commit
608086f092
1 changed files with 10 additions and 0 deletions
10
readme.md
10
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};"
|
||||
|
|
Loading…
Reference in a new issue