Created
July 29, 2016 03:48
-
-
Save csm/d69a03e21d11fe81c1ec36ffdf273319 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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