mustache.clj 介绍
mustache.clj
是一个mustache模板的Clojure实现。
在开发Rssminer时,因需要一个更快更轻巧的模板库,而开发。
特点:
- 零依赖,小巧。包含源代码的jar仅16K
- 速度快。在i5机器上,一个测试中,每秒可生成约300M的HTML
- 通过Macro,完成模板到函数的转化,使用简单
示例代码:
(deftemplate template (slurp "test/sample.tpl")) (def data {:title "mustache.clj" :desc "Logic-less {{mustache}} templates for Clojure" :tags [{:tag "Clojure"} {:tag "Mustache"} {:tag "Performance"}]}) (println (template data)) <!-- 模板 test/sample.tpl --> <h1>{{ title }}</h1> <p class="desc">{{ desc }}</p> <ul> {{#tags}} <li class="tag">{{ tag }}</li>{{/tags}} {{# hidden }} this will not show, if hidden is false or empty list {{/ hidden }} </ul> 输出: <h1>mustache.clj</h1> <p class="desc">Logic-less {{mustache}} templates for Clojure</p> <ul> <li class="tag">Clojure</li> <li class="tag">Mustache</li> <li class="tag">Performance</li> </ul>
mustache.clj 官网
https://github.com/shenfeng/mustache.clj
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。