Getting Started

Download velocity2js

Download the velocity2js from sourceforge.net.

Install velocity2js

Just extract the downloaded zip archive.

Usage

java -jar Velocity2Js.jar -d <template-dir> <output-dir> [<resource-file>]
<template-dir> = directory where template are located (sub-dirs will be processed too)
<output-dir> = directory where the generated js file (vel2js.js) will saved
[<resource-file>] = optional name of resource bundle, used for internationalization (eg: ../template/mybundle)
or
java -jar Velocity2Js.jar -f <base-dir> <input-file> <output-file> [<resource-file>]

Ant Task

Add following lines to your ant file:

<taskdef name="vel2js" classname="at.riemers.velocity2js.velocity.Velocity2JsTask" 
         classpath="<velocity2js-dir>/Velocity2Js.jar;
                    <velocity2js-dir>/velocity-1.5.jar; 
	            <velocity2js-dir>/lib/commons-collections-3.1.jar; 
	            <velocity2js-dir>/lib/commons-lang-2.1.jar; 
                    <velocity2js-dir>/lib/commons-logging.jar; 
                    <velocity2js-dir>/lib/commons-logging.jar; 
	            <velocity2js-dir>/velocity-1.5/lib/log4j-1.2.12.jar;"/>
    

<vel2js templateDir="<template-source-dir>" 
           javascriptDir="<javascript-output-dir>" 
           [javascriptName="<javascript-file>"] 
           [resource="<resource-file>"] >        
		   
        <fileset dir="<template-source-dir>" casesensitive="yes">
            <include name="**/*.vm"/>    
        </fileset>              
</vel2js>
  

Read more about velocity2js ant task in User Guide - Ant Task.