Reputation: 47441
Below is my app -
(ns mfaiz.routes
(:use [net.cgrand.moustache :only [app]]
[net.cgrand.enlive-html :only [deftemplate content]]
[ring.util.response :only [response]]))
(deftemplate reg "mfaiz/templates/reg.html" [])
(def my-app (app
["hi"] "Hello World!"
["reg"] (-> ((-> "reg" symbol resolve)) response constantly)
[&] "Nothing was found"))
I encounter error with this route -
["reg"] (-> ((-> "reg" symbol resolve)) response constantly)
If I evaluate the above route directly, it works properly and returns the html file -
((-> "reg" symbol resolve))
If I also change the route to directly call the template function then also it works -
["reg"] (-> (reg) response constantly)
Any ideas what is going wrong ?
Upvotes: 2
Views: 116
Reputation: 33637
The problem seems to be the fact that when it run under ring, the "reg" is not being resolved because the it is not fully qualified. It depends in which namespace the ring server is started. So using fully qualified name will work:
(-> "mfaiz.routes/reg" symbol resolve)
Please check resolve
documentation. It tries to resolve the symbol in current namespace i.e in *ns*
Upvotes: 2