(compile bindings & forms)
This partially evaluates expressions in the given wisp forms. You will want this if you want to pass arguments to the generated javascript. For example:
(compile [comment-id "comment-123"] (let [add-class (fn [el class-name] (.add (.-classList el) class-name))] (add-class (document.getElementById comment-id) "hidden")))
will result in this Javascript:
(function () { var addClassø1 = function (el, className) { return el.classList.add(className); }; return addClassø1(document.getElementById('comment-123'), 'hidden'); }.call(this));
Note that the symbol resolution is symbol-based and dumb, so if you're shadowing a variable in a nested scope or something, things will likely break.
This partially evaluates expressions in the given wisp forms. You will want this if you want to pass arguments to the generated javascript. For example: (compile [comment-id "comment-123"] (let [add-class (fn [el class-name] (.add (.-classList el) class-name))] (add-class (document.getElementById comment-id) "hidden"))) will result in this Javascript: (function () { var addClassø1 = function (el, className) { return el.classList.add(className); }; return addClassø1(document.getElementById('comment-123'), 'hidden'); }.call(this)); Note that the symbol resolution is symbol-based and dumb, so if you're shadowing a variable in a nested scope or something, things will likely break.
(evaluate-forms & forms)
Given forms that are correct wisp expressions, returns the compiled JS output:
(evaluate-forms (def the-qux 23) (foo :bar the-qux))
;=> "var theQux = 23; foo('bar', theQux);"
Note that this does not evaluate any forms inside the expressions. If you need this, use compile
Given forms that are correct wisp expressions, returns the compiled JS output: (evaluate-forms (def the-qux 23) (foo :bar the-qux)) ;=> "var theQux = 23; foo('bar', theQux);" Note that this does not evaluate any forms inside the expressions. If you need this, use `compile`
(evaluate-str expr)
(evaluate-str expr source-mapping?)
Compile a wisp expression string into Javascript. The source-mapping? argument defines whether or not the JS will include mapping data to the wisp expression.
Compile a wisp expression string into Javascript. The source-mapping? argument defines whether or not the JS will include mapping data to the wisp expression.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close