Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
Checking mergeability… Don’t worry, you can still create the pull request.
  • 2 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
View
2 samples/hello-js/.gitignore
@@ -0,0 +1,2 @@
+out/
+hello*.js
View
33 samples/hello-js/README.md
@@ -0,0 +1,33 @@
+Simple ClojureScript Project Example Using an External JavaScript Library
+
+One-time Setup
+==============
+
+- Create a CLOJURESCRIPT_HOME environment variable which points to the
+ ClojureScript root directory.
+
+- If you have not already done so, execute
+
+ $CLOJURESCRIPT_HOME/script/bootstrap
+
+- Add $CLOJURESCRIPT_HOME/bin to your PATH.
+
+Run in Development Mode
+=======================
+
+Development mode allows for each file to be loaded in a separate script tag so
+that errors can be easily tracked to the offending file.
+
+ cljsc src > hello-js.js
+
+After running the above command, open hello-js-dev.html. Notice that each required
+JavaScript file has been loaded in its most readable form.
+
+Run Optimized JavaScript
+========================
+
+Once an application is ready for production, a single optimized file can be produced.
+
+ cljsc src {:optimizations :advanced} > hello-js.js
+
+After running the above command, open hello-js.html to view the result.
View
18 samples/hello-js/hello-js-dev.html
@@ -0,0 +1,18 @@
+<html>
+ <head>
+ <title>Hello External JavaScript Library</title>
+ </head>
+ <body>
+ <h1>Hello External JavaScript Library!</h1>
+ <!-- In unoptimized mode, additional script tags are required -->
+ <script type="text/javascript" src="out/goog/base.js"></script>
+ <script type="text/javascript" src="my-external-lib.js"></script>
+ <script type="text/javascript" src="hello-js.js"></script>
+ <script>
+ goog.require('hello_js.core');
+ </script>
+ <script>
+ hello_js.core.popup_msg('JavaScript calling a ClojureScript function');
+ </script>
+ </body>
+</html>
View
13 samples/hello-js/hello-js.html
@@ -0,0 +1,13 @@
+<html>
+ <head>
+ <title>Hello External JavaScript Library</title>
+ </head>
+ <body>
+ <h1>Hello External JavaScript Library!</h1>
+ <script type="text/javascript" src="my-external-lib.js"></script>
+ <script type="text/javascript" src="hello-js.js"></script>
+ <script>
+ hello_js.core.popup_msg('JavaScript calling a ClojureScript function');
+ </script>
+ </body>
+</html>
View
3 samples/hello-js/my-external-lib.js
@@ -0,0 +1,3 @@
+function send_alert(msg) {
+ alert("Sending Alert via " + msg + "!");
+};
View
9 samples/hello-js/src/hello/core.cljs
@@ -0,0 +1,9 @@
+(ns hello-js.core)
+
+(defn ^:export popup-msg
+ [msg]
+ (js/send_alert msg))
+
+(popup-msg "ClojureScript calling a global function defined in an external JavaScript library")
+
+(popup-msg (str "ClojureScript: the time is now " (js/Date.)))

No commit comments for this range

Something went wrong with that request. Please try again.