【问题标题】:how to reload the template when working with enlive without restar使用enlive时如何重新加载模板而不重新启动
【发布时间】:2012-09-09 03:00:02
【问题描述】:

我正在使用 enlive 进行 Web 开发。我使用(serve my-app/handler) 在repl 中启动我的环服务器

但是,当我对我的任何 html 模板进行更改时,我必须重新启动我的 repl 才能显示更改。如何在不重新启动 repl 的情况下重新加载我的标记?

谢谢, 穆尔塔萨

【问题讨论】:

    标签: clojure ring enlive


    【解决方案1】:

    您需要重新评估读取模板的行。例如,在我的项目中,我必须重新评估(Emacs 中的“C-x C-e”)以下行:

    (def table-template (h/html-resource "META-INF/web/table.html"))
    

    如果您不使用 Emacs,您可以尝试包含带有 :reload 的模板的 require 命名空间,请参阅:force clojure :reload

    【讨论】:

    • 感谢您的回复。但是,如果我使用 deftemplate - (deftemplate chrome "mfaiz/templates/chrome.html" [page] [:#main] (content "Hello World"))),我该如何重新加载它
    • 您应该可以这样做:重新评估此表达式或定义模板的整个命名空间。如果你看一下deftemplate 的定义,它会调用template,它按顺序调用html-resource
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-18
    • 2010-09-08
    • 1970-01-01
    • 1970-01-01
    • 2018-10-13
    相关资源
    最近更新 更多