问题
I'm learning clojure and I work on project where I'm using compojure & ring & clostache (mustache for clojure).
This is my core clojure file:
(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")
)
My question is: How I can include CSS files in my .mustache files? Is this problem related to .mustache extension or something about compojure way of working?
PS: With link tag css file is not found (404).
回答1:
If you created the project using compojure template with lein
, then there is a directory under your project root named ${project_root}/resources/public
. The static files like .html
, .js,
, .css
can reside in the directory.
For example, you can make the directory structure like this:
${project_root}/resources/public/index.html
/js/util.js
/css/style.css
In the above structure, you can access index.html
by /index.html
, and style.css
by /css/style.css
, and so on.
来源:https://stackoverflow.com/questions/32484636/how-to-include-css-files-into-compojure-project