Skip to content

crmdias/execjs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Execjs

Build Status

Support via Gratipay

Execjs allows you run JavaScript from Elixir. It can automatically pick the best runtime available on the system.

Runtimes

Execjs supports the following runtimes:

Use the application environment (application key: :execjs, key: :runtime) to set the runtime Execjs uses. Alternatively, the EXECJS_RUNTIME environment variable can also be used to set the runtime.

Usage

eval

iex> Execjs.eval "'red yellow blue'.split(' ')"
["red", "yellow", "blue"]

compile/call

iex> {source, 0} = System.cmd("curl", ["-sL", "--compressed", "https://rawgit.com/jashkenas/coffeescript/master/extras/coffee-script.js"])
iex> context = Execjs.compile(source)
iex> Execjs.call(context, "CoffeeScript.compile", ["square = (x) -> x * x"])
"(function() {\n  var square;\n\n  square = function(x) {\n    return x * x;\n  };\n\n}).call(this);\n"

About

Run JavaScript code from Elixir

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Elixir 79.5%
  • HTML 20.5%