Template Template = velocity.gettemplate ("Test.wm"); Context context = new Velocitycontext (); Context.put ("foo", "Bar"); Context.put ("Customer", New Customer ()); Template.merge (context, writer); When the Velocity.gettemplate method is invoked, the Resourcemanger's corresponding method is invoked. Resourcemanger first see if the template file is in cache, if not, get it, generate the resource object and invoke the process () method, determine whether the template is valid, and, if it is, generate a node tree in memory. When Template.merge () is invoked, the node tree is traversed and the Render method of each node is invoked. For variables and object node in the template, the Execute () method is also invoked to obtain value from the context. Note: Resourcemanger under Runtime/resource Package, node under Runtime/parser/node package |