mirror of
https://github.com/rails/execjs
synced 2023-03-27 23:21:20 -04:00
Code fence highlighting
This commit is contained in:
parent
9c02129a78
commit
59b772a0c2
1 changed files with 16 additions and 10 deletions
26
README.md
26
README.md
|
@ -17,23 +17,29 @@ ExecJS supports these runtimes:
|
||||||
|
|
||||||
A short example:
|
A short example:
|
||||||
|
|
||||||
require "execjs"
|
``` ruby
|
||||||
ExecJS.eval "'red yellow blue'.split(' ')"
|
require "execjs"
|
||||||
# => ["red", "yellow", "blue"]
|
ExecJS.eval "'red yellow blue'.split(' ')"
|
||||||
|
# => ["red", "yellow", "blue"]
|
||||||
|
```
|
||||||
|
|
||||||
A longer example, demonstrating how to invoke the CoffeeScript compiler:
|
A longer example, demonstrating how to invoke the CoffeeScript compiler:
|
||||||
|
|
||||||
require "execjs"
|
``` ruby
|
||||||
require "open-uri"
|
require "execjs"
|
||||||
source = open("http://jashkenas.github.com/coffee-script/extras/coffee-script.js").read
|
require "open-uri"
|
||||||
|
source = open("http://jashkenas.github.com/coffee-script/extras/coffee-script.js").read
|
||||||
|
|
||||||
context = ExecJS.compile(source)
|
context = ExecJS.compile(source)
|
||||||
context.call("CoffeeScript.compile", "square = (x) -> x * x", :bare => true)
|
context.call("CoffeeScript.compile", "square = (x) -> x * x", :bare => true)
|
||||||
# => "var square;\nsquare = function(x) {\n return x * x;\n};"
|
# => "var square;\nsquare = function(x) {\n return x * x;\n};"
|
||||||
|
```
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
|
|
||||||
$ gem install execjs
|
```
|
||||||
|
$ gem install execjs
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
# FAQ
|
# FAQ
|
||||||
|
|
Loading…
Reference in a new issue