我有一堆共享相同页眉和页脚的静态 html 文件。我想在所有页面上共享此页眉和页脚。现在我使用以下路由,但它有点难看,我必须处理所有特殊情况。有没有一种简单的方法可以做到这一点,例如 php 的 include 函数?
(defroutes my-app
(GET "/"
(html-with-template
"main.header" "index.body" "main.footer" ))
(GET "/*.html"
(html-with-template
"main.header" (str (params :*) ".body") "main.footer" ))
(GET "/*/"
(html-with-template
(str (params :*) "/folder.header")
(str (params :*) "/index.body")
(str (params :*) "/folder.footer")))
(GET "/*"
(or (serve-file (params :*)) :next))
(ANY "*"
(page-not-found)))