我正在学习 clojure,并且我正在使用 compojure 和ring & 元素clostache (clojure 的 mustache )。
这是我的核心 clojure 文件:
(defroutes public-routes
(GET "/" [] (controller/index))
(route/resources "/")
(GET "/index" [] (controller/index))
(route/resources "/")
(GET "/customers" [] (controller/customers))
(route/resources "/")
(GET "/employees" [] (controller/employees))
(route/resources "/")
)
(defroutes app-routes public-routes
(route/not-found "404 Not Found")
)
我的问题是:如何在我的 .mustache 文件中包含 CSS 文件?这个问题是否与 .mustache 扩展有关,或者与 compojure 的工作方式有关?
PS:未找到带有链接标记的 css 文件(404)。
最佳答案
如果您使用带有 lein
的 compojure 模板创建了元素,那么您的元素根目录下会有一个名为 ${project_root}/resources/public
的目录。 .html
、.js、
、.css
等静态文件可以驻留在该目录中。
例如,您可以将目录结构设为这样:
${project_root}/resources/public/index.html
/js/util.js
/css/style.css
在上面的结构中,您可以通过/index.html
访问index.html
,通过/访问
,等等。style.css
css/style.css
关于css - 如何将css文件包含到compojure元素中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32484636/