Clojure 使用enlive中src文件夹外部的模板

Clojure 使用enlive中src文件夹外部的模板,clojure,enlive,Clojure,Enlive,是否可以在enlive中从源文件夹外部提供模板 我想从我的resources/public/templates文件夹而不是src/templates文件夹中提取模板,我该怎么做 谢谢, Murtaza您是否尝试将包含模板的文件夹包含在类路径中。我相信enlive会查看您的类路径以找到您指定的模板 如果资源/公用文件夹已在类路径中,则模板路径应类似于 (deftemplate模板名称“templates/path/to/template”[] …)我将所有模板放在一个不在类路径上的文件中,并使用以

是否可以在enlive中从源文件夹外部提供模板

我想从我的resources/public/templates文件夹而不是src/templates文件夹中提取模板,我该怎么做

谢谢,
Murtaza

您是否尝试将包含模板的文件夹包含在类路径中。我相信enlive会查看您的类路径以找到您指定的模板
如果资源/公用文件夹已在类路径中,则模板路径应类似于

(deftemplate模板名称“templates/path/to/template”[]
…)

我将所有模板放在一个不在类路径上的文件中,并使用以下内容定义它们:

(defmacro deftemplate- [name source & rest]
  `(deftemplate ~name (java.io/File. (str "path-to-pages/" ~source)) ~@rest ) )

是的,是否可以从源文件夹外部提供模板。在我的情况下,它工作没有任何改变我的配置;我的模板在
/resources
中,静态资产在
/resources/public

注意:我在我的
项目中使用了以下内容。clj

:min-lein-version "2.0.0"
:plugins [[lein-ring "0.8.3"]]
:dependencies [[org.clojure/clojure "1.5.1"]
               [compojure "1.1.5"]
               [enlive/enlive "1.1.1"]]
我这样引用
/resources/index.html

(h/deftemplate index-template "index.html"
  [s]
  [:title] (h/content s))

谢谢,希德,这很有魅力。使用以下lein选项来规范>:资源路径[“src/main/resource”]如果按照约定进行,则无需指定完整路径;此外,这是冗长和重复的。