Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Clojure:带有Enlive的模板_Clojure_Enlive - Fatal编程技术网

Clojure:带有Enlive的模板

Clojure:带有Enlive的模板,clojure,enlive,Clojure,Enlive,我从中复制了一个非常基本的示例,但它没有编译: (ns web.handler (:require [compojure.core :refer :all] [compojure.handler] [compojure.route :as route] [net.cgrand.enlive-html :as html])) ;; Compiler throws in the next line, see the message below. (html/de

我从中复制了一个非常基本的示例,但它没有编译:

(ns web.handler
  (:require
    [compojure.core :refer :all]
    [compojure.handler]
    [compojure.route :as route]
    [net.cgrand.enlive-html :as html]))

;; Compiler throws in the next line, see the message below.
(html/deftemplate main-template "templates/index.html"
  []
  [:head :title] (html/content "Enlive starter kit"))

(defroutes app-routes
  (GET "/" [] "Hello")
  (GET "/ping/:what" [what] (str "<h1>Ping '" what "'</h1>"))
  (route/resources "/")
  (route/not-found "Not Found"))

(def app
  (compojure.handler/site app-routes))
我使用以下命令运行:

lein ring server-headless
如何让它工作

编辑

到目前为止,我的调查是:
enlivehtml.clj:54

(defn tagsoup-parser 
 "Loads and parse an HTML resource and closes the stream."
 [stream]
  (filter map?
    (with-open [^java.io.Closeable stream stream]
      (xml/parse (org.xml.sax.InputSource. stream) startparse-tagsoup)))) ; #54 

可能
org.xml.sax
未被引用?如何使用
lein
执行此操作?

当找不到模板文件时,通常会发生此错误。使用
templates/index.html
,它可以在
resources/templates
目录或
src/templates
目录中查找。

只不过是
templates
,移动到
src/tampletes
,效果很好<代码>资源/模板也可以使用。非常感谢。当我短暂浏览代码时,它进入
ClassLoader.getResourceAsStream
。我不熟悉Java基础架构,但这就是
resources/
src/
路径的来源?当您指定字符串路径时,Enlive使用内置的Java资源方法。这将搜索当前类加载器的类路径(由Leiningen使用项目配置和默认配置设置)。如果需要其他路径,可以将它们添加到project.clj中,也可以自己打开它并向deftemplate传递InputStream。
(defn tagsoup-parser 
 "Loads and parse an HTML resource and closes the stream."
 [stream]
  (filter map?
    (with-open [^java.io.Closeable stream stream]
      (xml/parse (org.xml.sax.InputSource. stream) startparse-tagsoup)))) ; #54