2011年9月17日 星期六

[Velocity] Brief Definition

* Velocity Template Language (VTL)
  • VTL uses references to embed dynamic content in a web site, and a variable is one type of reference.
  • Variables are one type of reference that can refer to something defined in the Java code, or it can get its value from a VTL statement in the web page itself.

Syntax:

##comment


#* comment *#


#directive
    
#end





$variable


#if ( expression)
#end


#foreach($item in $list)
    $item 
#end 


* When an online visitor requests your web page, the Velocity Templating Engine will search through your web page to find all # characters, then determine which mark the beginning of VTL statements, and which of the #characters that have nothing to do with VTL.

* #if
(i) $foo is a boolean (true/false) which has a true value, or
(ii) the value is not null. Remember that the Velocity context only contains Objects, so when we say 'boolean', it will be represented as a Boolean (the class).


* Reference
- Apache User Guide - Contents
- apache velocity介绍及资料: 可下載文件。
- Apache Velocity实现模板化的最简实例 - 玉米疯收 - 博客园: 圖解

沒有留言:

張貼留言