From: Olof-Joachim Frahm Date: Wed, 12 Jun 2013 20:20:54 +0000 (+0200) Subject: Add sequel.js to execute all CL script tags in a document. X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=acc36f143b0d192fbf69fa70bbb05faae2a72de6;p=jscl.git Add sequel.js to execute all CL script tags in a document. --- diff --git a/jscl.lisp b/jscl.lisp index 8378417..d5afb0f 100644 --- a/jscl.lisp +++ b/jscl.lisp @@ -158,7 +158,8 @@ (write-string (read-whole-file (source-pathname "prelude.js")) out) (do-source input :target (!compile-file input out)) - (dump-global-environment out)) + (dump-global-environment out) + (write-string (read-whole-file (source-pathname "sequel.js")) out)) ;; Tests (with-open-file (out "tests.js" :direction :output :if-exists :supersede) (dolist (input (append (directory "tests.lisp") diff --git a/src/sequel.js b/src/sequel.js new file mode 100644 index 0000000..ef429d4 --- /dev/null +++ b/src/sequel.js @@ -0,0 +1,13 @@ +/* execute all script tags with type of x-common-lisp */ +window.onload = (function () { + var scripts = document.scripts; + + for (var i = 0; i < scripts.length; ++i) { + var script = scripts[i]; + + /* TODO: what about errors? */ + if (script.type == "text/x-common-lisp") { + lisp.evalString(script.text); + } + } +});