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

目录
相关文章
|
前端开发
vuecli3打包报警告:chunk chunk-common [mini-css-extract-plugin] Conflicting order.
vuecli3打包报警告:chunk chunk-common [mini-css-extract-plugin] Conflicting order.
342 0
vuecli3打包报警告:chunk chunk-common [mini-css-extract-plugin] Conflicting order.
|
8月前
|
前端开发 图形学
Could you provide some examples of when Canvas or SVG would be the better choice for a web application?
Could you provide some examples of when Canvas or SVG would be the better choice for a web application
|
8月前
|
编解码 JavaScript 编译器
【Vue warn】If this is a native custom element, make sure to exclude it from component resolution ……
【Vue warn】If this is a native custom element, make sure to exclude it from component resolution ……
Parsing error: Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragmen
Parsing error: Adjacent JSX elements must be wrapped in an enclosing tag. Did you want a JSX fragmen
134 0
|
设计模式 JSON 编译器
Jetpack之Room的使用,结合Flow
Jetpack之Room的使用,结合Flow
254 0
Jetpack之Room的使用,结合Flow
|
JavaScript
Velocity ${} 、$!{}、!${}的区别
Velocity ${} 、$!{}、!${}的区别
- Templates should only be responsible for mapping the state to the UI. Avoid placing tags with side-effects in your templates, such as <script>, as t
vue.js报错如下: - Templates should only be responsible for mapping the state to the UI. Avoid placing tags with side-effects in your templates, such as , as they will not be parsed.
5662 1
|
Web App开发 JavaScript 前端开发
Is server side rendering a good choice for React application
Single page application like react provides a wonderful user experience, however, it comes with two issues: For user who accesses the website at first time, there is no cache of javascript files in
1531 0
|
JavaScript 前端开发 Ruby