#lang scheme/base (require "util.scm") (provide js-script-invoke js-array js-quote js-call ) (define (js-script-invoke . js-strs) `(script ((language "javascript")) ,(string-join js-strs "\n"))) (define (js-array scheme-lst) (string-append "[" (string-join scheme-lst ", ") "]")) (define (js-quote thing) (cond ((number? thing) thing) ((or (string? thing) (symbol? thing)) (format "'~A'" thing)) ((eq? thing #t) "true") ((eq? thing #f) "false") (else (e "Don't know how to js-quote ~A." thing)))) (define (js-call fn-name . args) (string-append fn-name "(" (string-join args ", ") ")"))