如何将CSS文件包含到compojure项目中? [英] How to include css files into compojure project?
问题描述
我正在学习Clojure,并且正在使用 compojure 环 & clostache (clojure的胡子)。
I'm learning clojure and I work on project where I'm using compojure & ring & clostache (mustache for clojure).
这是我的核心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")
)
我的问题是:如何在。胡子文件中包括CSS文件?这个问题是与。 mustache 扩展名有关还是与compojure的工作方式有关?
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:找不到带有链接标记的CSS文件(404) )。
PS: With link tag css file is not found (404).
推荐答案
如果您使用带有 lein
的compojure模板创建了项目,则项目根目录下有一个名为 $ {project_root} / resources / public
的目录。静态文件,例如 .html
, .js,
, .css
可以位于目录中。
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
在上述结构中,您可以通过 index.html
> /index.html 和 style.css
通过 /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.
这篇关于如何将CSS文件包含到compojure项目中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!