Skip to content

Instantly share code, notes, and snippets.

@csm
Created July 29, 2016 03:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csm/d69a03e21d11fe81c1ec36ffdf273319 to your computer and use it in GitHub Desktop.
Save csm/d69a03e21d11fe81c1ec36ffdf273319 to your computer and use it in GitHub Desktop.
(defn js-engine
[]
(if-let [engine (.getEngineByName (ScriptEngineManager.) "JavaScript")]
engine
(throw (Exception. "no JavaScript engine found. Sorry"))))
(defn run-slides-js
[s]
(let [engine (js-engine)
script (str "(function() {\n"
s "\n"
" return [slides, TIMES];\n"
"})();")]
(try
(map vals (vals (.eval engine script)))
(catch ScriptException _ nil))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment