small medium large xlarge

28 Nov 2013, 22:53
Marcus Brito (8 posts)

Using compojure.response.Renderable just to add a JavaScript variable for the context path seems way overkill to me.

I’m as new to Clojure as most people reading this book, but exploring the namespaces used so far, I think using noir.request/*request* is a better way:

(ns picture-gallery.views.layout
  (:require [noir.request :refer [*request*]]))


(defn base [& body]
     [:title "Welcome to picture-gallery"]
     (include-css "/css/screen.css")
     [:script {:type "text/javascript"} (str "var context=\"" (:context *request*) "\";")]
     (include-js "//")]
    [:body body]))

Skimming the Compojure documentation, it seems to me that Renderable would be more appropriate for cases where you need to render a complex type that’s not supported out of the box.

29 Nov 2013, 01:00
Dmitri Sotnikov (125 posts)

Using the *request* would be perfectly fine in this scenario. I thought this was a good opportunity to introduce protocols and Renderable in particular.

You must be logged in to comment