How to include css files into compojure project?

孤者浪人 提交于 2019-12-11 02:58:43

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!