a clojure library designed to render velocity template for ring in clojure.
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 :
(defroutes app-routes
(get "/" [] (render "test.vm" :name "dennis" :age 29))
(route/not-found "not found"))
use ring.velocity in :
(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 .
凯发天生赢家一触即发官网 copyright © 2012 dennis zhuang[killme2008@gmail.com]
distributed under the eclipse public license, the same as clojure.
home:
未使用type hint | 使用type hint |
// access flags 1 public invoke(ljava/lang/object;ljava/lang/object;ljava/lang/object;)ljava/lang/object; l0 linenumber 14 l0 l1 linenumber 14 l1 aload 1 aconst_null astore 1 ldc "substring" iconst_2 anewarray java/lang/object dup iconst_0 aload 2 aconst_null astore 2 aastore dup iconst_1 aload 3 aconst_null astore 3 aastore invokestatic clojure/lang/reflector.invokeinstancemethod (ljava/lang/object;ljava/lang/string;[ljava/lang/object;)ljava/lang/object; l2 localvariable this ljava/lang/object; l0 l2 0 localvariable s ljava/lang/object; l0 l2 1 localvariable begin ljava/lang/object; l0 l2 2 localvariable end ljava/lang/object; l0 l2 3 areturn maxstack = 0 maxlocals = 0 |
public invoke(ljava/lang/object;ljava/lang/object;ljava/lang/object;)ljava/lang/object; l0 linenumber 15 l0 l1 linenumber 15 l1 aload 1 aconst_null astore 1 checkcast java/lang/string aload 2 aconst_null astore 2 checkcast java/lang/number invokestatic clojure/lang/rt.intcast (ljava/lang/object;)i aload 3 aconst_null astore 3 checkcast java/lang/number invokestatic clojure/lang/rt.intcast (ljava/lang/object;)i invokevirtual java/lang/string.substring (ii)ljava/lang/string; l2 localvariable this ljava/lang/object; l0 l2 0 localvariable s ljava/lang/object; l0 l2 1 localvariable begin ljava/lang/object; l0 l2 2 localvariable end ljava/lang/object; l0 l2 3 areturn maxstack = 0 maxlocals = 0 |
文档: