【问题标题】:How to include css files into compojure project?如何将 css 文件包含到 compojure 项目中?
【发布时间】:2015-12-05 17:20:51
【问题描述】:

我正在学习 clojure,我正在使用 compojure & ring & clostache (clojure 的小胡子)

这是我的核心 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)。

【问题讨论】:

  • 您的 css 文件在哪里?你能拿到它们吗? (例如,通过在浏览器中访问 localhost:port/css/yourfile.css)。

标签: css clojure compojure ring


【解决方案1】:

如果您使用带有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,通过/css/style.css 访问style.css,以此类推。

【讨论】:

  • 我在资源中没有公用文件夹。非常感谢! :)
猜你喜欢
  • 2014-09-23
  • 1970-01-01
  • 2016-04-16
  • 1970-01-01
  • 1970-01-01
  • 2019-04-07
  • 1970-01-01
  • 2012-07-27
  • 1970-01-01
相关资源
最近更新 更多