Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

JS macros test fix and readme updates #11

Open
wants to merge 3 commits into from

2 participants

@ibdknox

These are simple, non-functional changes that correct a typo in the defjsmacro test and adds js macros to the readme.

ibdknox added some commits
@ibdknox ibdknox fixed invalid test due to paren misplacement
Signed-off-by: Chris Granger <ibdknox@gmail.com>
a43e50f
@ibdknox ibdknox add JS macros to the readme
Signed-off-by: Chris Granger <ibdknox@gmail.com>
6970cf3
@ibdknox ibdknox final readme fix
Signed-off-by: Chris Granger <ibdknox@gmail.com>
86130f1
@arohner
Owner

This patch doesn't apply cleanly, I suspect because of the version number change. I'll apply it when it does cleanly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 13, 2011
  1. @ibdknox

    fixed invalid test due to paren misplacement

    ibdknox authored
    Signed-off-by: Chris Granger <ibdknox@gmail.com>
  2. @ibdknox

    add JS macros to the readme

    ibdknox authored
    Signed-off-by: Chris Granger <ibdknox@gmail.com>
  3. @ibdknox

    final readme fix

    ibdknox authored
    Signed-off-by: Chris Granger <ibdknox@gmail.com>
This page is out of date. Refresh to see the latest.
Showing with 29 additions and 4 deletions.
  1. +26 −1 README.markdown
  2. +2 −2 project.clj
  3. +1 −1  test/test_scriptjure.clj
View
27 README.markdown
@@ -201,6 +201,31 @@ If you want to pass a js form from one clojure function to another, use js*
`cljs` and `cljs*` are shortcuts for `(js (clj ...))` and `(js* (clj ..))` respectively. Note that both only take one form.
+JS Macros
+=======
+You can create custom JS Macros using `scriptjure/defjsmacro`:
+
+```clojure
+(defjsmacro on-ready [& body]
+ (.ready ($ document) (clj (list* (concat '(fn []) body)))))
+
+(js (on-ready (alert "hello")))
+
+=> "$(document).ready(function() {
+ alert(\"hello\");
+ })"
+```
+Any time you want to evaluate a clojure variable in your macro, simply wrap it in a `(clj)` call:
+
+```clojure
+(defjsmacro custom-alert [person]
+ (alert (str "hello " (clj person))))
+
+(js (custom-alert "Joe"))
+
+=> "alert(\"hello \" + \"Joe\")"
+```
+
License
=======
-Scriptjure is licensed under the EPL, the same as Clojure core. See epl-v10.html in the root directory for more information.
+Scriptjure is licensed under the EPL, the same as Clojure core. See epl-v10.html in the root directory for more information.
View
4 project.clj
@@ -1,4 +1,4 @@
-(defproject scriptjure "0.1.22"
+(defproject com.ibdknox.scriptjure/scriptjure "0.1.23"
:description "a clojure DSL for generating javascript"
:url "http://github.com/arohner/scriptjure"
- :dependencies [[org.clojure/clojure "1.2.0"]])
+ :dependencies [[org.clojure/clojure "1.2.0"]])
View
2  test/test_scriptjure.clj
@@ -173,6 +173,6 @@
(is (get-custom 'prn-hw)))
(deftest custom-form-use
- (is (= (js (prn-hw "custom"))) "alert(\"hello world custom\")"))
+ (is (= (js (prn-hw "custom")) "alert(\"hello world \" + \"custom\")")))
(run-tests)
Something went wrong with that request. Please try again.