阅读332 返回首页    go 阿里云 go 技术社区[云栖]


Ring.velocity:render velocity templates for ring in clojure

Home: https://github.com/killme2008/ring.velocity

A Clojure library designed to render velocity template for ring in clojure.

Usage

Adds dependency in leiningen project.clj:

  [ring.velocity "0.1.0-SNAPSHOT"] 

Create a directory named templates in your project directory to keep all velocity templates.

Create a template templates/test.vm:

  hello,$name,your age is $age. 

Use ring.velocity in your namespace:

  (use '[ring.velocity.core :only [render]]) 

Use render function to render template with vars:

  (render "test.vm" :name "dennis" :age 29) 

The test.vm will be interpreted equals to:

  hello,dennis,your age is 29. 

Use ring.velocity in compojure:

  (defroutes app-routes      
(GET "/" [] (render "test.vm" :name "dennis" :age 29))
(route/not-found "Not Found"))

Use ring.velocity in ring:

  (use '[ring.util.response])   
(response (render "test.vm" :name "dennis" :age 29))

Custom velocity properties,just put a file named ring-velocity.properties to your classpath or resource paths.The default velocity properties is in src/default/velocity.properties.

License

Copyright © 2012 dennis zhuang[killme2008@gmail.com]

Distributed under the Eclipse Public License, the same as Clojure.

Home: https://github.com/killme2008/ring.velocity


文章转自庄周梦蝶  ,原文发布时间2012-07-18

最后更新:2017-05-18 20:37:08

  上一篇:go  一文告诉你,大数据在智慧医疗领域发挥的作用
  下一篇:go  Clojure笔记:用好type hint