问题
Am using clojure - 1.5.1, compojure - 1.1.5, clostache - 1.3.1.
The template file is present under resources/public/templates folder.
Code :
(:require [clostache.parser :as cp])
(cp/render-resource "templates/connectionDetails.mustache" {:jmsConnectionName "Michael" :rest-conn-names ["a" "b"]}))
The call to Clostache's render-resource is throwing the below Exception :
Exception: java.lang.IllegalArgumentException: No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil
core_deftype.clj:541 clojure.core/-cache-protocol-fn
io.clj:73 clojure.java.io/fn[fn]
io.clj:106 clojure.java.io/reader
RestFn.java:410 clojure.lang.RestFn.invoke
AFn.java:161 clojure.lang.AFn.applyToHelper
RestFn.java:132 clojure.lang.RestFn.applyTo
core.clj:619 clojure.core/apply
core.clj:6278 clojure.core/slurp
RestFn.java:410 clojure.lang.RestFn.invoke
parser.clj:396 clostache.parser/render-resource
回答1:
The resource is probably not found because your path seems to be incorrect. resources
is added to the classpath so to access your template you should use "public/templates/connectionDetails.mustache"
(it might not make sense to have the templates under public
if you do not expose them directly from your application).
回答2:
Your templates should be located under the source folder. In your case that would be:
src
|
- templates
|
- connectionDetails.mustache
The public folder is used for HTML resources pulled from the web application client, i.e CSS, Images, Javascripts etc ...
Clostache is looking at your classpath (i.e src folder) to find the files it needs.
来源:https://stackoverflow.com/questions/19196745/clojure-clostache-error-no-implementation-of-method-make-reader-of-protocol