Skip to content

Instantly share code, notes, and snippets.

@jhchabran
Last active August 29, 2015 14:04
Show Gist options
  • Save jhchabran/fc755c84afc539b8df0f to your computer and use it in GitHub Desktop.
Save jhchabran/fc755c84afc539b8df0f to your computer and use it in GitHub Desktop.
Rails + ClojureScript
  • Drop project.clj in Rails root
  • copy _clojurescript.html.erb into /app/views/shared/
  • update your layout according to application.html.erb
  • replace project-name by your project name
  • run the following:
lein cljsbuild auto &
bundle exec rails s

public/assets/ has to be commited if you want to host it on heroku.

<script src="/assets/dist/goog/base.js" type="text/javascript"></script>
<script src="/assets/project-name.js" type="text/javascript"></script>
<script type="text/javascript">goog.require("project-name.core");</script>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><%= content_for?(:title) ? yield(:title) : "ProjectName" %></title>
<%= csrf_meta_tags %>
</head>
<body>
Content goes here.
<%= render 'shared/clojurescript' %>
</body>
</html>
(defproject project-name "0.1.0-SNAPSHOT"
:description "FIXME: write this!"
:url "http://example.com/FIXME"
:dependencies [[org.clojure/clojure "1.6.0"]
[org.clojure/clojurescript "0.0-2268"]
[secretary "1.2.0"]]
:plugins [[lein-cljsbuild "1.0.4-SNAPSHOT"]]
:source-paths ["src"]
:cljsbuild {
:builds [{:id "project-name"
:source-paths ["app/assets/javascripts/project-name"]
:compiler {
:output-to "public/assets/project-name.js"
:output-dir "public/assets/dist"
:optimizations :none
:source-map true}}]})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment