首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Clojure: Enlive模板

Clojure: Enlive模板
EN

Stack Overflow用户
提问于 2013-09-17 22:21:35
回答 1查看 833关注 0票数 1

我从https://github.com/cgrand/enlive复制了一个非常基本的示例,但它没有编译:

代码语言:javascript
复制
(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))

我得到的错误:

代码语言:javascript
复制
java.lang.NullPointerException, compiling:(handler.clj:9:1)

我带着命令跑:

代码语言:javascript
复制
lein ring server-headless

怎么让它起作用?

编辑

到目前为止我的研究:来自enlive-html.clj:54的错误抛出

代码语言:javascript
复制
(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做到这一点?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-09-17 22:35:59

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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18860859

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档