[Home]TagTemplateEngine

GvTags | RecentChanges | Preferences

The TagTemplateEngine can execute GTL templates from Groovy, from Java, as an ant task or from the command line.

It is a sub class of groovy.text.TemplateEngine. Some methods are added to make usage of the template engine more easy.


Using the TagTemplateEngine from the command line

With the all-in-one release the template engine can simply be called from the command line. Just enter:

  gvtags -f template.gtl
This will run the template engine on the file template.gtl. For full list of arguments see command line parameters.


Using the TagTemplateEngine from Groovy

To use the TagTemplateEngine from Groovy is very easy. You just need to include two libraries to your class path, these libraries are gvtags-<release>.jar and jsp-api.jar (the jsp-api.jar is only needed because some classes of the tag lib need jsp classes.) You can find the libs in the directory structure of the all-in-one release at lib/gvtags-<release>.jar and additional-libs/servlet-api/jsp-api.jar.

The easiest way to include these libraries is just by copying them to the lib directory of your groovy installation. Then they are available for all groovy programms.

Testing the TagTemplateEngine from Groovy

After including gvtags-<release>.jar and jsp-api.jar to your class path, try to execute:

  groovy -e 'println new gvtags.TagTemplateEngine().evaluateString("This template prints <%= 4700+11%>")'

Or go to the directory src/gvtags/examples of the Source Release of GvTags and start

  groovy printCalendar.groovy


Using the TagTemplateEngine from Java

Calling the TagTemplateEngine from Java is nearly as easy as calling it from Groovy. You only have to include some more libs, especially the Groovy libs.

Have a look at the libs of the all-in-one release in the directories lib/ and additional-libs/

You can find a Java example in gvtags/examples/PrintCalendar.java


Using the TagTemplateEngine from Ant

The template engine can easily be called from ant, see Ant task.


GvTags | RecentChanges | Preferences
This page is read-only | View other revisions
Last edited July 27, 2006 4:56 pm by Tof (diff)
Search:
Hosted by BerliOS Developer Logo, cohosted at SourceForge.net Logo