以下是我的应用 -
(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"))
我遇到这条路线的错误 -
["reg"] (-> ((-> "reg" symbol resolve)) response constantly)
如果我直接评估上述路线,它会正常工作并返回html文件 -
((-> "reg" symbol resolve))
如果我也改变了直接调用模板函数的路径,那么它也可以工作 -
["reg"] (-> (reg) response constantly)
任何想法出了什么问题?
答案 0 :(得分:1)
问题似乎是,当它在环下运行时,“reg”没有得到解决,因为它不是完全合格的。它取决于环服务器启动的命名空间。因此,使用完全限定名称将起作用:
(-> "mfaiz.routes/reg" symbol resolve)
请检查resolve
documentation。它试图解析当前名称空间中的符号,即*ns*