Thanks to visit codestin.com
Credit goes to github.com

Skip to content

CORS support and multiple expressions (file-level compile) #30

@emnh

Description

@emnh

CORS support

I implemented CORS support in a fork so that the compiler can be used from AJAX clients on other hosts (see this example). If you want you can just diff my fork and pick up the CORS stuff, but I also did some other small stuff so I would need to clean it up if you want me to send a proper pull request. My fork is running here.

File compile as a service

What is the best way to add a http://host/compile-file API to compile a whole file of s-expressions instead of just one expression? I'm currently trying to integrate with JSBin. I have a working demo in a JSBin fork, but it just takes one expression in the file like the REPL.

What is the best workaround given the current compilation scheme, that is, compile a file, which is basically just a list of expressions, as one expression? I figured it works fine wrapped in a let expression. For example the following runs in my JSBin fork:

(let []

(ns cljs.user)

(def paper (js/Raphael. 10, 50, 320, 200))

(defn makeCircle
   [x]
   (let 
     [circle (.circle paper x x 10)]
      (.attr circle "fill" "#0000ff")
      (.attr circle "stroke" "#ffffff")
      circle))

(def circles (map makeCircle (range 10 100 10)))
(doall circles)
(js/console.log (str circles))

)

Error handling

How can I get better error messages from the compiler to report to JSBin? How can I catch exceptions that occur with the reader in clj-params? I suppose I should disable it and explicitly call read-string on expr.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions