jgdbcq
Last Updated: February 25, 2016
·
1.595K
· bajesse
Brian

Fix Resource context when deploying Clojure Noir to Glassfish/Tomcat

Place this in your namespace:

(:require [noir.request :as request])

Add a helper function:

(defn add-context [url]
  (str (:context (request/ring-request)) url))

use it like this in hiccup:

[:script {:type "text/javascript" :src (add-context "myscript.js")}]

or better yet make a new abstract js include function:

(defpartial include-js [& scripts]
  (for [script scripts]
    [:script {:type "text/javascript" :src
      (add-context script)}]))
Say Thanks
Respond