---
---
Templates for Java

Welcome to my humble Java templates page. It is a general text based templating system. It is very easy to use and very powerful. It can be used for almost anything - starting from code generation at translators/compilers to HTML outputing at Java servlets.

Latest release: jtlt-0.4.tar.gz at 13-10-2003.

Features

  • Replaceable keys
  • Block structure, blocks can be nested
  • Extensible macro system (actually even keys are implemented as macros)
  • Separation of parsing and output generation
  • Separation of macro settings and parsing
  • Due to last two points we'll get in memory caching of parsed templates
  • Designed to be fast
  • Syntax of macro directives can be redefined
  • Macros can have macros generate their arguments
  • Macros can be recursive, eg. macro output can be post-parsed for macro tags
  • Html template specialization
  • Localization database support for the html template, aliases
  • Weak typing, no exceptions on every little thing
  • Well documented API

Download

The code is downloadable here: jtlt-0.4.tar.gz. It already contains all the documentation and a jar file so you don't have to do much work to get it running. Code is distributed under the GNU "lesser" public license (GNU LGPL).

Changelog

  • 2003-10-13 release 0.4
    • Fixed couple of minor bugs
    • Lock at front works now
    • Little bug with argumentless macros
    • Added new macro SepMacro - for easy separator sub creation
    • New major feature - macro shortcuts, see example6
    • Reader class to get better output from templates
  • 2003-09-30 release 0.3
    • Change the text based alias database interface to FilebasedAliasDatabase
    • Introduced mass replace functions into Template and HtmlTemplate
    • API change, replaceall renamed to nreplace
    • API change, encoding functions now have consistent naming at HtmlTemplate
    • Added two new examples, changed some examples, better documented now
    • Better support for internationalization, charset at TemplateContext
    • New macros: UrlKeyMacro
  • 2003-09-12 release 0.2
    • Build system moved to ant
    • Major cleanup of API, changed a lot, well we're at 0.1 so don't complain
    • Did away with the constructors at Template, now always get Template through TemplateGenerator
    • Macro arguments can now contain macros
    • Macro output can be recursive
    • Implemented html specialization template - HtmlTemplate*
    • Localization support
    • New macros: HtmlKeyMacro, EncloseMacro, IncludeMacro, JsKeyMacro, AliasMacro

Documentation

The package is well documented and I have also provided several examples so it should be easy for you to get started. The javadoc generated API documentation is also available inline.

Examples

Here are six examples (java, template file, output):

UML diagram

---
Copyright © 2001-2024 Indrek Mandre