Search code examples
clojureclojurescript

Working through the Untangled Template


I'm very interested in using CLJS and Untangled to make a dynamic web app. I have some very basic questions, though. My first question is: I see that like in other frameworks, there is a base index.html that has a .js file reference and the <div id="app"></div> is tied to the javascript file.

So in the Untangled Template project from github, I have my Figwheel server running and I wanted to do some tinkering on the dev-index side.

<body>
    <div class="container-fluid" id="app"><div>Now loading super sweet app</div></div>
    <script src="js/untangled_template.js" type="text/javascript"></script>
</body>

However, there's no file called untangled_template.js and I'm wondering what would be the bare minimum scaffolding for such a .js file.

Having used Clojure, but not really broken into Clojurescript yet, I'm curious how this .js file comes to be (since presumably it's first written in cljs)

Thanks many


Solution

  • Disclaimer: I've never used Untangled.

    This line of the Untangled template's project.clj is probably what you're looking for. Note how in the :cljsbuild section of this file, there are several builds listed - when you run lein figwheel, the dev profile is used, and whenever you make changes to your cljs code, Figwheel compiles your cljs (note the :source-paths part of this build map) and puts the generated JS in resources/public/js/untangled_template.js.

    You say you're not seeing an untangled_template.js file - do you mean that you don't see a file with that name in the root directory of your Leiningen project, or do you mean that when you load your index.html in a Web browser it complains that it can't find /js/untangled_template.js?